Skip to content
Browse files

Add the INVALID_STATE_ERR post

  • Loading branch information...
1 parent ecabeb1 commit ca18f8d04b7b8e4db88da4436ba8a90a65f68a41 @Dinduks committed Feb 20, 2013
Showing with 22 additions and 0 deletions.
  1. +22 −0 source/_posts/2013-02-18-websockets-invalid-state-err-dom-exception-11.markdown
View
22 source/_posts/2013-02-18-websockets-invalid-state-err-dom-exception-11.markdown
@@ -0,0 +1,22 @@
+---
+layout: post
+title: "WebSockets: INVALID_STATE_ERR: DOM Exception 11"
+date: 2013-02-18 09:34
+comments: true
+categories:
+---
+
+This error can be caused by many reasons, among them what happened to me: I tried
+sending a message via the WebSocket before the connection was completely opened.
+
+What you should _not_ do:
+
+ ws = new WebSocket("ws://localhost/ws");
+ ws.send('foo');
+
+What you should do instead:
+
+ ws = new WebSocket("ws://localhost/ws");
+ ws.onopen = function () {
+ ws.send('foo');
+ }

0 comments on commit ca18f8d

Please sign in to comment.
Something went wrong with that request. Please try again.