This speeds up CasperJS tests by 25 seconds per main app page load.
When we switched the SockJS, the casper tests got inexplicably slower. I
finially figured out what's going on. The first SockJS XHR request (remember
that we don't get websockets in the test suite) gets considered part of the page
load and therefore the PhantomJS onLoadFinished handler doesn't get called until
the SockJS XHR finishes, which happens at the heartbeat, 25 seconds later. To
fix this, we simply don't create the SockJS object on page load since it will be
created on demand, anyway.
(imported from commit 845a97526c5102df426cd6fc26182a734e7fcab6)
We've only gotten one error report for this error, and it didn't have a stack
trace, so it's hard to know whether this will actually fix the issue or not.
(imported from commit 7bff052347a33f67d8479b1cb23f6e5e24defc75)
Without an explicit close, we will continue to get messages on the old
connection, even once we replace the _sockjs property. This leads to
"impossible" situations, such as receiving ACKs after reconnecting.
(imported from commit f8927fdf0551610e5b9d1db29bba00e160e76b6d)
There will be browser errors on staging when this is deployed due to the socket
protocol changing.
(imported from commit f1eda5b5c2ec9c60c23b3ca96277a61debadf5bb)
This will hopefully help with the send dialog being stuck on
"sending" as well as allowing us to not show errors to the user on
reconnect.
(imported from commit 31ee889853f348e486863073dc130cdfb4e1338d)
Clients can only have one connection at a time, anyway, so we can
just keep track of a client id, instead. This makes reconnections
easier.
It's a little funny to use queue ids for the client id, but we know
they should exist by the time the client is connecting and they are
guaranteed to already be unique and authenticatable. We will also
eventually be integrating the event system and the socket code closer
anyway.
(imported from commit 1f60e06fb16d31d6c121deafd493fb304d19a6c2)
Previously, if the user held down the enter button while the socket
was disconnected, the client would try to connect in a very tight
loop. Now we throttle reconnection attempts to 1 per second.
(imported from commit 7b18260b992d5a34f3ea7925cf72b383f84bbabd)
If the user has a flaky connection, we might be in the backoff state
of attempting a reconnect. But when the user regains connectivity
and tries to send, we want to send the message as soon as possible.
(imported from commit 3c5c8e9c3104ff7923258f73c9ab700548518d16)
There seems to be some sort of bug involving PhantomJS and XHR
streaming messages. When successive pages are loaded that use XHR
streaming, PhantomJS seems to think the second one never finishes
loading and therefore hangs.
(imported from commit db93b4cab816f1fdc3f3f543c9394b1cba8abedb)
Because our authentication system reads cookies from the initial
connection attempt, several SockJS transports can't be used.
(imported from commit 34b9571225d39072985b8223fb12c43c7235841f)