Skip to content

Conversation

@ereslibre
Copy link

If the socket is destroyed, node.js from 0.8.20 version will raise an error here.

@ereslibre
Copy link
Author

Any comments on this ? Maybe is better to handle this exception directly on the packet function ?

@itbra
Copy link

itbra commented Feb 19, 2013

I'm not sure, if your error is the same as mine (some log information was helpful), but i encounter this kind of error too with Node 0.8.20 and latest Socket.IO, but only with IE 8 so far. With Chrome-based Browsers all is fine. Here is, was is logged after page reload.

D:\Users\Max\Desktop\key2swap>node server.js
info - socket.io started
debug - served static content /socket.io.js
debug - client authorized
info - handshake authorized tWkqNsJCuGZCXRenDxrS
debug - setting request GET /socket.io/1/xhr-polling/tWkqNsJCuGZCXRenDxrS?t=1361287530225
debug - setting poll timeout
debug - client authorized for
debug - clearing poll timeout
debug - xhr-polling writing 1::
debug - set close timeout for client tWkqNsJCuGZCXRenDxrS
debug - setting request GET /socket.io/1/xhr-polling/tWkqNsJCuGZCXRenDxrS?t=1361287530239
debug - setting poll timeout
debug - discarding transport
debug - cleared close timeout for client tWkqNsJCuGZCXRenDxrS
debug - served static content /socket.io.js
debug - client authorized
info - handshake authorized jfWlV0KGe0q67c0rDxrT
debug - setting request GET /socket.io/1/xhr-polling/jfWlV0KGe0q67c0rDxrT?t=1361287539750
debug - setting poll timeout
debug - client authorized for
debug - clearing poll timeout
debug - xhr-polling writing 1::
debug - set close timeout for client jfWlV0KGe0q67c0rDxrT
debug - setting request GET /socket.io/1/xhr-polling/jfWlV0KGe0q67c0rDxrT?t=1361287539868
debug - setting poll timeout
debug - discarding transport
debug - cleared close timeout for client jfWlV0KGe0q67c0rDxrT
debug - clearing poll timeout

timers.js:103
if (!process.listeners('uncaughtException').length) throw e;
^
Error: socket hang up
at createHangUpError (http.js:1360:15)
at ServerResponse.OutgoingMessage._writeRaw (http.js:507:26)
at ServerResponse.OutgoingMessage._send (http.js:476:15)
at ServerResponse.OutgoingMessage.write (http.js:749:16)
at XHRPolling.doWrite (D:\Users\Max\Desktop\key2swap\node_modules\socket.io\lib\transports\xhr-polling.js:67:17)
at XHRPolling.HTTPPolling.write (D:\Users\Max\Desktop\key2swap\node_modules\socket.io\lib\transports\http-polling.js:132:8)
at XHRPolling.Transport.packet (D:\Users\Max\Desktop\key2swap\node_modules\socket.io\lib\transport.js:515:15)
at Object. (D:\Users\Max\Desktop\key2swap\node_modules\socket.io\lib\transports\http-polling.js:79:12)
at Timer.list.ontimeout (timers.js:101:19)

Any help was highly appreciated, as otherwise this app cannot be used on our sites, if it is not cross-browser stable.

@ereslibre
Copy link
Author

On 02/19/2013 04:36 PM, clubnite wrote:

I'm not sure, if your error is the same as mine (some log information
was helpful), but i encounter this kind of error too, but only with IE 8
so far. With Chrome-based Browsers all is fine. Here is, was is logged
after page reload.

I can reproduce it always on Chromium 24, Firefox 18, with xhr-polling.

It is very important to use node.js 0.8.20, that is the version that
introduced the exception.

You need also to emit something from the server to the client. The
polling was fixed with the previous merge, but when emitting is when
this error happened.

If you can't reproduce tell me and I can give you a backtrace on the go.

Best regards,
Rafael Fernández López.

@ereslibre
Copy link
Author

@clubnite: your backtrace looks like what my last commit (merged) fixed, please update your working copy, since I guess it could be so.

The error I mean is when the server emitted something to the client, and still failing. (fixed by the commit on this pull request).

However it would make sense to take care of this error at a lower level.

@ghost
Copy link

ghost commented Feb 20, 2013

Using node.js 0.8.20 with socket.io 0.9.13.
Catching error in /lib/transports/xhr-polling.js at line 67 (this.response.write(data)), fixed it for me.

@zendozerris
Copy link

Hi
Got same problem on a clean new install of everything (debian, node, etherpad .. most of all)
node.js 0.8.20
socket.io 0.9.11

At RANDOM TIME and EVERYTIME by switching from a pad to the timeline page, error log :
FATAL ERROR !!
[2013-02-20 01:41:30.987] [DEBUG] socket.io - clearing poll timeout
[2013-02-20 01:51:40.065] [ERROR] console - Error: socket hang up
at createHangUpError (http.js:1360:15)
at ServerResponse.OutgoingMessage._writeRaw (http.js:507:26)
at ServerResponse.OutgoingMessage._send (http.js:476:15)
at ServerResponse.OutgoingMessage.write (http.js:749:16)
at XHRPolling.doWrite (/usr/lib/etherpad-lite/src/node_modules/socket.io/lib/transports/xhr-polling.js:67:17)
at XHRPolling.HTTPPolling.write (/usr/lib/etherpad-lite/src/node_modules/socket.io/lib/transports/http-polling.js:132:8)
at XHRPolling.Transport.packet (/usr/lib/etherpad-lite/src/node_modules/socket.io/lib/transport.js:515:15)
at Object. (/usr/lib/etherpad-lite/src/node_modules/socket.io/lib/transports/http-polling.js:79:12)
at Timer.list.ontimeout (timers.js:101:19)
[2013-02-20 01:51:40.065] [INFO] console - graceful shutdown...
[2013-02-20 01:51:40.143] [INFO] console - db sucessfully closed.
RESTART!

Doing your trick : Catching error in /lib/transports/xhr-polling.js at line 67 (this.response.write(data)), fixed it for me. WORK for me
but for newbee, here is what i have done

file : src/node_modules/socket.io/lib/transports/xhr-polling.js

Find :
67 >> this.response.write(data);
Replace :
67 << try
68 << {
69 << this.response.write(data);
70 << }
71 << catch(err)
72 << {
73 << this.log.debug("FVP #49105 Error description: " + err.message + "\n\n",data)
74 << }

And now for me, no more reboot of the etherpad server
This is quite a little bug, but with it, we could'nt put it in production
So sad for an amazing program like etherpad-lite

Ok, for now it work
but be careful, i'am not sure of that, it could be just a nasty patch

@jacob
Copy link

jacob commented Feb 21, 2013

I can confirm that this is a reproducible error. I have a Phonegap app which runs a socket.io client. In the pause method which is called when the app is moved to the background I call disconnect() on the socket.io client. The server gets the disconnect message but by the time it sends the response back the client app has been moved to the background by the phone operating system and its connection has been cut. I was getting the error described in this thread 100% of the time in this situation, crashing the socket.io server app.

I implemented the error catch inside lib/transports/xhr-polling.js as described by zendozerris and it resolves the issue. I would definitely recommend pulling a fix for this into socket.io.

@keyosk
Copy link
Contributor

keyosk commented Feb 22, 2013

I can confirm this in IE 8 running node 0.8.20 and socket 0.9.13. Almost every single time I hard refresh with IE 8 I see this error on my server. I noticed a large reduction in these by wrapping a check around every emit I do, to ensure that there is a socket connected, but this isn't perfect and the disconnects still seem to error.

@zendozerris
Copy link

True
I confirm too
After three or four CTRL+R quickly pressed, the etherpad server hang on connection and restart
And true too, i just made a patch to avoid an error to stop the program, but the error isn't solved
i think it s a question of execution time.

@kurteknikk
Copy link

Is this issue fixed with the new version of node ? (v0.8.21)

@kurteknikk
Copy link

I had a very similar issue (not sure if it's the same one that you are having), but for me now it seems to be working much better.

@suprsidr
Copy link

I can confirm this in IE 9 running node 0.8.20 and socket 0.9.13. Every refresh w/IE9 crashes my application, thankfully forever is there to rescue.

events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: socket hang up
at createHangUpError (http.js:1360:15)
at ServerResponse.OutgoingMessage._writeRaw (http.js:507:26)
at ServerResponse.OutgoingMessage._send (http.js:476:15)
at ServerResponse.OutgoingMessage.end (http.js:887:18)
at HTMLFile.HTTPTransport.doClose (/usr/home/me/node/blog/node_modules/socket.io/lib/transports/http.js:110:17)
at HTMLFile.Transport.close (/usr/home/me/node/blog/node_modules/socket.io/lib/transport.js:429:10)
at HTMLFile.Transport.end (/usr/home/me/node/blog/node_modules/socket.io/lib/transport.js:462:10)
at HTMLFile.Transport.onSocketClose (/usr/home/me/node/blog/node_modules/socket.io/lib/transport.js:157:8)
at Socket.EventEmitter.emit (events.js:126:20)
at Socket._destroy.destroyed (net.js:358:10)

@suprsidr
Copy link

Also getting a lot of these w/ this build:

warn - Unable to serve file. EMFILE, open '/usr/home/me/node/blog/node_modules/socket.io/node_modules/socket.io-client/bin/../lib/transports/jsonp-polling.js'

@suprsidr
Copy link

Seems to be fixed in node 0.8.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants