Socket.io on FF 11 and Chrome 18.0? - node.js

I am having some issues with websockets and socket.io.
On localhost, socket.io seems to work ok but when I push to production on no.de, on FF 11 and Chrome 18.0, it takes forever to connect and after about 5 seconds the connection is lost and not reestablished. It works fine on Safari. This is with and without configuring the transports with websocket included.
When I configure the transports without 'websocket', all is well, connections are quick and not dropped. So I have it working now, but not as I would like it to.
Two things I am confused on:
- I thought these browser versions supported websockets.
- I thought socket.io would default to the next best transport solution.
Any ideas on what I'm doing wrong?

It seems that No.de servers don't proxy correctly. I don't know the details. I've found the info here:
http://discuss.joyent.com/viewtopic.php?id=30975
You won't get the job done unless you pay! As always. :-)

Related

Google App Engine - socket.io throws errors before successfully connect

Ok so... For a while web sockets have been implemented in the GAE flex environment.
I've got an app deployed there and everything works "sorta" fine except that sometimes
When Connecting or
After a random disconnect and it tries to reconnect
I get a couple of these errors:
POST https://XXX.appspot.com/socket.io/?EIO=3&transport=polling&t=N00Ml-1&sid=XuKv8-6R2TZrIERGAAAO 400
WebSocket connection to 'wss://XXX.appspot.com/socket.io/?EIO=3&transport=websocket&sid=XuKv8-6R2TZrIERGAAAO' failed: WebSocket is closed before the connection is established
GET https://XXX.appspot.com/socket.io/?EIO=3&transport=polling&t=N00Ml-2&sid=XuKv8-6R2TZrIERGAAAO 400
I've googled a lot and tried a lot of the stuff suggested to people that had similar issues (most of them BEFORE GAE introduced websocket support).
After a couple of these errors it just connects and everything is fine... I've tried forcing transport as websocket on the client side but it doesn't seem to change anything.
Is there any fix? Should i just change cloud provider?
Not posting any code since it's the basic socket.io nodejs implementation, in fact I've tested with an empty basic implementation and it's the same thing, my best guess is they havn't implemented the load balancer correctly? Anybody has these issues? Should i go aws instead?
I managed to fix this... I've posted on the socket.io github issues
https://github.com/socketio/socket.io/issues/3543
And here's a link to a better explanation
https://github.com/socketio/socket.io/issues/3612#issuecomment-656667871

Node.js and Socket.IO Not Responding in Some Servers

I have simple Node.js and Socket.IO app running on Nodejitsu. The App is running perfectly from home and some other Internet services but not working from my work!
Here is the error Message which I am getting
The connection to ws://behseini-socketproject.jit.su/socket.io/1/websocket/QtVm6E79WwGLwBVjN7el was interrupted while the page was loading.
this.websocket = new Socket(this.prepareUrl() + query);
socket.io.js (line 2371)
GET http://behseini-socketproject.jit.su/socket.io/1/?t=1370531712581 200 OK
535ms
socket.io.js (line 1659)
ParamsHeadersResponse
fPtjDNnugmPPXKbnN7ep:60:60:websocket,htmlfile,xhr-polling,jsonp-polling
Can you please let me know why this is happening? is this kind of Firewall issue?
Thanks
After talking with you on the #nodejitsu IRC channel, it seems that this may indeed be a problem with your work proxy/firewall.
As was suggested to you in the chat last night, you could always try to use secure websocket connections (wss rather than ws) to see if that will allow your connections to pass through.
If that doesn't work, you would need to send your connection outside of your work's connection. For instance, proxying into a computer at your home and using your home network while you're at work and want to use websockets.

socket.io websocket connection invalid (latest chrome)

After installing node.js, I followed this tutorial to start a simple chat server. It was very easy to setup and is working, but I have noticed two problems:
1.) I am getting this warning from socket.io
info - socket.io started
debug - served static /socket.io.js
debug - client authorized
info - handshake authorized 1385647068766475337
debug - setting request GET /socket.io/1/websocket/1385647068766475337
debug - set heartbeat interval for client 1385647068766475337
warn - websocket connection invalid
This doesn't make sense to me because I didn't touch anything with socket.io and I am using the latest chrome version (23) which I know supports websockets (I am able to successfully connect to them with PHP-Websockets). It continues to use XHR instead, but I am really interested in getting the Websocket functionality working.
2.) When I go to localhost:8080 to connect to the chat server, it takes around 7-8 seconds for it to prompt me for my name and actually connect me to the server. I have a feeling this may be because it is reverting to XHR, but I don't really know much about it so I can't say. Any thoughts?
I saw this behaviour when using an older version of socket.io with later chrome builds (and other browsers also). It would timeout then fallback to xhr polling. To check your version of the socket.io library you are using, at your shell (linux/unix) type:
npm ls| grep socket.io
And it should tell you the version. The latest at this time is 0.9.13, which works.
If you are running the tutorial from http://psitsmike.com note that the package.json file hardcodes an older version of socket.io which doesn't work with the latest browsers.
Hope this helps.
I too was facing similar issues.
Your case -
Try deleting your cookies, sometimes the xhr-polling option once connected successfully is saved to cookies and reused every next time. Similar question answered here
Also debug - served static /socket.io.js sometimes come when the socket.io file is referred incorrectly inside the html or jade template file. Try correcting the script src link in case it wrong. It should be something like - var socket = io.connect('http://localhost:3000'); OR you can also try removing the link all together like this - var socket = io.connect();
Hope it helps.
I had the exact same issue. this might be old. but My setup is on digitalocean. what happens is that usually people who run node apps on one server use nginx for the port listen and node under its own dedicated port. nginx did not forward the websocket port to the node, only port 80 which nodejs was not initialised to begin with.
http://nginx.org/en/docs/http/websocket.html
You need to make sure your nginx is configured properly for this.
I just added the port to the io.connect directly connecting to the node server and avoiding nginx.

Socket.IO setting poll timeout

I'm using Socket.IO on Node.js.
The Example here: http://socket.io/#how-to-use
First Example.
I have tested on my computer, it works great. ( Installed on VPS, connect by IP. not localhost )
But the problem is, my friends, they visit the page:
http://112.78.8.221:8085/
Press F12 for debug , under Console, they show not thing.
But in my browser console ( Chrome, Firefox ) , I see a object return.
On debug of my friend:
I see :
jsonppolling closed due to exceeded duration
setting request GET /socket.io/1/jsonp-polling/blablabalblabal
Setting poll timeout
discatding transport and same as xhr-polling, timeout and discard.
So, both of us used latest version of Chrome and FF, can u guys help on this one? a week with this problem already :(
I believe there is something strange going on with his network. Maybe he is going through a proxy connection or something? I was able to hit your service and got an object back without a problem. Some offices and universities will also block ports other than the common 80, 443, 22, etc. If you can, try hosting on a lower port number, or if possible on port 80 to eliminate that as a cause of the problem.

Node.js and socket.io - problems in Opera browser

I use a browser - Opera version 11.52.
I use version of the node.js - v0.4.12 and socket.io version 0.8.5.
I tried this example - https://github.com/LearnBoost/socket.io/tree/master/examples/chat
This page starts up and displays only the message - Connecting to socket.io server = In opera.
Other browsers work properly - Firefox, IE, Chrome.
I tried to debug node.js - No errors.
Thank you for your help and advice!
Try following this guide: https://github.com/LearnBoost/Socket.IO/wiki/Configuring-Socket.IO and configuring the transports setting to something that prioritizes xhr-polling over websockets and see if that resolves the issue. My experience with using socket.io on production web apps has been that the websocket transport is not as reliable as xhr-polling.
Did you try to enable Websocket? Put in your toolbar, then check, then save.
opera:config#UserPrefs|EnableWebSockets

Resources