socketio / socket.io

Realtime application framework (Node.JS server)
https://socket.io
MIT License
60.8k stars 10.09k forks source link

Crash Socket.io when 2 connections at the same moment #644

Closed zelkin closed 12 years ago

zelkin commented 12 years ago

Hi all, i've a problem with a repetitive crash on socket.io. In fact, when i launch 2 connection in the same time (with 2 browsergame), i've this error :

[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 Socket. (/home/smet/node/www/test.js:42:8) at Socket.$emit (events.js:64:17) at SocketNamespace.handlePacket (/home/smet/node/node_modules/socket.io/ lib/namespace.js:335:22) at Manager.onClientMessage (/home/smet/node/node_modules/socket.io/lib/m anager.js:459:38) at WebSocket.onMessage (/home/smet/node/node_modules/socket.io/lib/trans port.js:387:20) at Parser. (/home/smet/node/node_modules/socket.io/lib/transp orts/websocket/hybi-07-12.js:40:10) at Parser.emit (events.js:64:17) at /home/smet/node/node_modules/socket.io/lib/transports/websocket/hybi- 07-12.js:286:16[/code]

I use socket.io with net.js to connect on an other server.

Do you know what is the problem ?

3rd-Eden commented 12 years ago

Looks like the problem is with your code:

at Socket._writeOut (net.js:391:11)
at Socket.write (net.js:377:17)
at Socket.<anonymous> (/home/smet/node/www/test.js:42:8)

So idk what is test.js on line 42

zelkin commented 12 years ago

test.js is my server page like server.js for example

cd node/www ---> to arrive in my www folder node test.js ---> to execute this page

3rd-Eden commented 12 years ago

Yes but what is in your test.js file, are you doing your net.connection stuff around line 42. If so, then it's not related to Socket.IO

zelkin commented 12 years ago

16 io.sockets.on('connection', function (socket) { 18 var conn = net.createConnection(1547,'88.154.14.25'); 19 conn.setEncoding('binary'); ... 38 //---------- SOCKET CLIENT ------------ 39 socket.on('recMsg',function(mess){ 40 socket.emit('newMsg', mess); // send broadcast 41 conn.write(mess.msg,'utf8'); // Send to IA Server 42 }); 43 }); //end socketio connection

zelkin commented 12 years ago

it's when the server socket.io send 2 message in the same time at line 41 :S

3rd-Eden commented 12 years ago

you are not checking on like 41 if you can write to your net connection, thats why you get errors. I'm closing this as it's clearly not a Socket.IO related issue.