News for hackers. Stuff that matters.
Re:You might not need a WebSocket by tribaal on Thursday July 10, 2014 @12:30PM (#8015546)
I live in Africa.

Websockets suck here. BGP routers here flap very often, nuking TCP connections because hey, power cuts. Guess what happens?

Tip: If you're "out to change the world", make sure you can turn your wifi card every 30 seconds and still get a decent-ish experience (yes, long-polling HTTP works, so does good old timer-based polling).

Re:You might not need a WebSocket by jkarneges on Thursday July 10, 2014 @12:40PM (#8015602)
Indeed. These days, you have to expect users will wander out of their wi-fi range or have crappy mobile connections. Whenever I ride the train with my 4G tether, my TCP sockets die every few miles.

I lose ssh and my websockets, but long-polling apps keep working. Kind of ridiculous, but that's the world we live in.

Making your websockets resilient means pinging and aggressive reconnecting.

Re:You might not need a WebSocket by mdpye on Thursday July 10, 2014 @02:58PM (#8016486)
If the connections are dropped quietly (client side does not find out the connection is gone) then how does the long poll case know that the existing poll conn is not going to return any data and a new one needs to be initiated?

Or is it just that long polls generally have short timeout compared with what you might implement for a websocket ping?

Re:You might not need a WebSocket by jkarneges on Thursday July 10, 2014 @03:37PM (#8016737)
Correct, long polling clients generally have timeouts. I wouldn't say they are necessarily shorter or longer than typical websocket ping intervals (I've seen as low as 20 seconds and as long as 2 minutes), but they do need to be there for the client to recover quickly.
Re:You might not need a WebSocket by saosebastiao on Thursday July 10, 2014 @12:49PM (#8015662)
It would be nice if you could drop the http overhead for long-polling though, which is the main reason I use websockets.
Re:You might not need a WebSocket by tribaal on Thursday July 10, 2014 @01:01PM (#8015751)
I'm fine with sending a couple of extra kb if that means I actually get an answer :)
Re:You might not need a WebSocket by timmclean on Thursday July 10, 2014 @12:51PM (#8015684)
It sounds like EventSource would be a good solution in that case: low overhead, and you'd get auto reconnect for free.
Re:You might not need a WebSocket by Svenstaro on Thursday July 10, 2014 @01:13PM (#8015836)
Have you tried http://mosh.mit.edu/?
Re:You might not need a WebSocket by tribaal on Thursday July 10, 2014 @01:27PM (#8015918)
Mosh is great, I use it on an almost daily basis.

Setting an alias like "alias sssh='mosh'" greatly helps with muscle memory, too (of course, don't override "ssh", you might still need it).

Funny anecdote: I live in a city called "Moshi"

Re:You might not need a WebSocket by icebraining on Thursday July 10, 2014 @05:02PM (#8017285)
I don't recommend replacing ssh, but when you do want to shadow a command, you can always call the original using \, e.g.:

  \ssh
Re:You might not need a WebSocket by jkarneges on Thursday July 10, 2014 @01:16PM (#8015849)
That looks awesome. Will definitely check it out. Broken ssh connections make me sad.
Re:You might not need a WebSocket by nawitus on Thursday July 10, 2014 @01:05PM (#8015775)
Have you tried socket.io-based web applications on the train? It does pings and reconnecting.
Re:You might not need a WebSocket by different-opini on Thursday July 10, 2014 @01:30PM (#8015935)
Do you know of any public socket.io apps?
Re:You might not need a WebSocket by nawitus on Thursday July 10, 2014 @02:01PM (#8016117)
Etherpad uses socket.io.

Here's one hosted Etherpad: https://etherpad.wikimedia.org/

Re:You might not need a WebSocket by jexe on Thursday July 10, 2014 @02:02PM (#8016125)
Dasher (http://dasher.im), uses socket.io. We're using socker.IO-objc for our iOS client: https://github.com/pkyeck/socket.IO-objc

And will be launching a web client in the coming weeks.

So far, so good. We do handle the reconnects ourselves, but otherwise it's been treating us well.

Re:You might not need a WebSocket by Udo on Thursday July 10, 2014 @02:59PM (#8016496)
So if connection resets are the problem, as opposed to router/proxy software problems... In cases where long polling seems to work as you say, why wouldn't an automatic WebSocket reconnect work just as well?
Re:You might not need a WebSocket by jkarneges on Thursday July 10, 2014 @03:31PM (#8016711)
You're right, in that case it'll work just as well. The problem is that it's easy to get wrong, so the developer needs to know what he/she is doing.

Fortunately wrappers like Socket.io, SockJS, Primus, etc can help with this.

Re:You might not need a WebSocket by mzs on Thursday July 10, 2014 @01:21PM (#8015880)
Also it just completely falls down in the case of many proxy servers and often the end user has no control over that.