Adjust to the real server

The socket.onopen function does not behave the way I thought it did. It runs
before the socket is actually open, but I was using it to tell the server I was
ready to receive a message. Then the server was sending me a message before the
socket was really ready and I missed it. The stackoverflow solution was to put
in a timeout and notify the server by hand after the timeout.