socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

throw new Error('Socket is not writable');

Open tommypowerz opened this issue 15 years ago • 12 comments

stable node and socket 0.8.4

seems like it happens during heartbeat...

is there a way to catch this error on my side?

thanks for help


net.js:391 throw new Error('Socket is not writable'); ^ Error: Socket is not writable at Socket._writeOut (net.js:391:11) at Socket.write (net.js:377:17) at WebSocket.write (/var/www/web17/chatserver/node_modules/socket.io/lib/transports/websocket/hybi-07-12.js:130:17) at WebSocket.packet (/var/www/web17/chatserver/node_modules/socket.io/lib/transport.js:515:15) at WebSocket.heartbeat (/var/www/web17/chatserver/node_modules/socket.io/lib/transport.js:330:10) at Object._onTimeout (/var/www/web17/chatserver/node_modules/socket.io/lib/transport.js:301:12) at Timer.callback (timers.js:83:39)

Program exited with code 01.

tommypowerz avatar Oct 02 '11 15:10 tommypowerz

Are you able to reproduce this reliably?

einaros avatar Oct 02 '11 15:10 einaros

yes.. just need to run my server.. and wait... it takes some hours....

by the way i can see tons of this one: warn - client not handshaken client should reconnect

tbey come so fast, that you cannot see the "valid log action"

tommypowerz avatar Oct 02 '11 15:10 tommypowerz

Could you pull my fork, at http://github.com/einaros/socket.io, and see if you still get the same errors? There are a few changes there (about to be merged with the main fork) which could improve stability.

einaros avatar Oct 02 '11 16:10 einaros

ok... on the next crash, i will get your version of code......

thanks guys...

tommypowerz avatar Oct 02 '11 16:10 tommypowerz

now it crashed again... will get your source now.....

but this time with a different message:

assert.js:93 throw new assert.AssertionError({ ^ AssertionError: true == false at Timer.callback (timers.js:82:11)

Program exited with code 01.

tommypowerz avatar Oct 02 '11 20:10 tommypowerz

i run node v0.412 and this http://github.com/einaros/socket.io

my server is getting stabler... sometimes it crashes due to segmantion faults:

Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fd0a4cf36f0 (LWP 24039)] 0x000000000062a873 in v8::internal::FlexibleBodyVisitor::Visit () Current language: auto; currently asm

and sometimes i had this error: can this somehow be catched? i cannot find a send or emit without try/catch in my code

net.js:391 throw new Error('Socket is not writable'); ^ Error: Socket is not writable at Socket._writeOut (net.js:391:11) at Socket.write (net.js:377:17) at WebSocket.write (/var/www/web17/chatserver/node_modules/socket.io/lib/transports/websocket/hybi-07-12.js:180:17) at WebSocket.packet (/var/www/web17/chatserver/node_modules/socket.io/lib/transport.js:515:15) at WebSocket.heartbeat (/var/www/web17/chatserver/node_modules/socket.io/lib/transport.js:330:10)

at Object._onTimeout (/var/www/web17/chatserver/node_modules/socket.io/lib/transport.js:301:12) at Timer.callback (timers.js:83:39)

Program exited with code 01.

tommypowerz avatar Oct 05 '11 22:10 tommypowerz

@tommypowerz you should always add a http://nodejs.org/docs/v0.4.12/api/process.html#event_uncaughtException_ also does this still occur in socket.io 0.8.5

3rd-Eden avatar Oct 11 '11 07:10 3rd-Eden

Just wanted to note that the SSL equivalent of this trace (for the original issue is):

        tls.js:70
            throw new Error('CryptoStream is not writable');
                  ^
        Error: CryptoStream is not writable
            at CleartextStream.write (tls.js:70:11)
            at WebSocket.write (/.../vendor/socket.io-node/lib/transports/websocket/hybi-07-12.js:130:17)
            at WebSocket.onDispatch (/.../vendor/socket.io-node/lib/transport.js:222:10)
            at Manager.onDispatch (/.../vendor/socket.io-node/lib/manager.js:342:31)
            at SocketNamespace.packet (/.../vendor/socket.io-node/lib/namespace.js:156:16)
            at Socket.packet (/.../vendor/socket.io-node/lib/socket.js:199:56)
            at Socket.emit (/.../socket.io-node/lib/socket.js:351:15)
            at /.../server.js:159:24
            at Client.get (/.../vendor/socket.io-node/lib/stores/memory.js:86:3)
            at Socket.get (/.../vendor/socket.io-node/lib/socket.js:248:14)

I'm still seeing this on 0.8.5, although I think the line numbers are slightly different (from the above snippet).

Is there a procedure in place for re-establishing the connection (or whatever is the appropriate action) when it's determined a socket isn't writable? I know there's error handling in place in the Transport for generic socket errors, but it's obviously not catching this. It seems like it may actually be an issue with node, letting an uncaught exception bubble up rather than dispatching an error event. Then again, I'm no where near familiar enough with the code base (yet) to speak to what's the intention/responsibility of that handler.

jasonwebster avatar Oct 13 '11 21:10 jasonwebster

Actually, this is probably a dupe of #512.

jasonwebster avatar Oct 13 '11 21:10 jasonwebster

Experiencing the same issue intermittently:

net.js:391 throw new Error('Socket is not writable'); ^ Error: Socket is not writable at Socket._writeOut (net.js:391:11) at Socket.write (net.js:377:17) at WebSocket.write

Node Setup


Node v0.4.12 Socket.io v0.8.5

The logs are also showing a very high volume of:

39m client not handshaken client should reconnect

Any feedback on how to resolve?

stewartl60 avatar Oct 18 '11 16:10 stewartl60

I'll fix this for the websocket transports tomorrow.

einaros avatar Oct 18 '11 17:10 einaros

Thanks einaros, that will be amazing.

stewartl60 avatar Oct 19 '11 16:10 stewartl60