Logging and debugging

    Before 1.0, the Socket.IO server would default to logging everything out to the console. This turned out to be annoyingly verbose for many users (although extremely useful for others), so now we default to being completely silent by default.

    The basic idea is that each module used by Socket.IO provides different debugging scopes that give you insight into the internals. By default, all output is suppressed, and you can opt into seeing messages by supplying the env variable (Node.JS) or the localStorage.debug property (Browsers).

    You can see it in action for example on our homepage:

    or in the browser:

    And then filter by the scopes you’re interested in. You can prefix the with scopes, separated by comma if there is more than one. For example, to only see debug statements from the socket.io client on Node.js try this:

    To see all debug messages from the engine and socket.io:

    If you are using webpack, you can remove it with webpack-remove-debug:

    Error logs in the browser console

    Please note that error logs such as:

    • net::ERR_INTERNET_DISCONNECTED
    • net::ERR_CONNECTION_REFUSED
    • Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at xxx. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
    • The connection to xxx was interrupted while the page was loading

    are not emitted by the Socket.IO library but by the browser itself, and are therefore out of our control.