ActionCable was throwing a "Existing connection must be closed before
opening" exception which was being picked up as a production issue in
our error monitoring software. Since this happens pretty often on any
device that allows the browser to sleep (mobile) this error was getting
triggered often.
This change removes the exception, but keeps logging the occurrence. We
now return `false` to let the caller now that `open` failed.
This is primarily for backwards compatibility for when
or if the protocol is changed in future versions.
If the server fails to respond with an acceptable
protocol, the client disconnects and disables
the monitor.
* More intention revealing than connecting on the first call to Connection#send
* Fixes that calls to Connection#send would attempt to open a connection when the WebSocket's state is CONNECTING
This change makes ping into a message type, which
makes the whole protocol a lot more consistent.
Also fixes hacks on the client side to make this all
work.
We are seeing cases where the websockets get stuck in the 'closing' state
after a tab has been in background for a while. So lets treat those websockets
as closed.