kipraske / web-brogue

Play brogue in a web browser
GNU General Public License v2.0
20 stars 17 forks source link

Server Crashes on ECONNRESET #24

Closed kipraske closed 9 years ago

kipraske commented 9 years ago

The error is Error:read ECONNRESET within express.js.

It seems from my research online this is caused by an abrupt connection loss to the TCP connection, and since I don't handle it - the server goes down. Very important to fix.

kipraske commented 9 years ago

Attempting to fix this by having http server and ws server on a different port. Doesn't happen too often so I am going to leave open for now.

kipraske commented 9 years ago

Using domains I have deduced that this error is coming internally from the wss object. That sucks since there is little we can do about that then since there is not really an interface to listen to the error.

The good news is that the error seems to imply that the client refused data, which just means that the browser will not get a frame back... which really isn't a big deal. Unfortunately it will be hard to communcate this to the user eh?

ilyvion commented 9 years ago

There are no client events to listen to for this particular event? Is it a server-side only thing?

kipraske commented 9 years ago

Yeah it is a server side thing only. It should be caught with the line that says wss.on("error" ...) but the library is not perfect and they didn't do it.

So now I am using nodejs domains in a way that they are not quite intended, but it seems to be working well for me. In this case I am just listening for unhandledExceptions and then if they are this exception I just catch it and carry on... and hope that there are no side effects from this unstable situation...

I fear that this may create a memory leak. But for now, yay no more server crashing. Fixed with v1.0.1