2

basically it is a rehash of this question: Cannot connect using WebSockets, not changing readyState

Which was not really answered.

I see on the server side:

[nlubin@localhost www]$ php -q /var/www/html/realTime/server/startDaemon.php
2011-03-15 13:49:30 System: Socket Resource id #7 created.
2011-03-15 13:49:30 System: Socket bound to localhost:7332.
2011-03-15 13:49:30 System: Start listening on Socket.

I am using the client and socket from this NetTuts: start using html5 websockets today
When i first go to the client it says in the box Socket Status: 0
and the server says:

2011-03-15 13:51:53 WebSocket: Resource id #8 CONNECTED!
2011-03-15 13:51:53 WebSocket: Requesting handshake...
2011-03-15 13:51:53 WebSocket: Handshaking...
2011-03-15 13:51:53 WebSocket: Done handshaking...

Then when i send anything it says: "Error: INVALID_STATE_ERR: DOM Exception 11"

If i click disconnect it disconnects..

Can anyone help?

Community
  • 1
  • 1
Naftali
  • 144,921
  • 39
  • 244
  • 303

2 Answers2

4

I got the same error when I was trying to send a message through websocket before it was connected. Make sure your sending logic is triggered in websocket's .onopen handler (or after it).

skalee
  • 12,331
  • 6
  • 55
  • 57
2

make sure your server/browser implement the same version of the websocket draft specification.

check http://en.wikipedia.org/wiki/WebSockets for the implementation status of your browser. If you are using chrome, your browser is most probably in draft-76.

In the comment section of the tutorial you are using someone says the tutorial uses the draft-75.

the comment mentions this other tutorial : http://bohuco.net/blog/2010/07/html5-websockets-example/ which is implementing draft-76

I hope this will help you,

Jerome Wagner

Jerome WAGNER
  • 21,986
  • 8
  • 62
  • 77