Invalid State Error Dom Exception 11 Websocket
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more invalidstateerror dom exception 11 xmlhttprequest about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Dom Exception 11: An Attempt Was Made To Use An Object That Is Not, Or Is No Longer, Usable.
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each safari invalidstateerror dom exception 11 other. Join them; it only takes a minute: Sign up INVALID_STATE_ERR: DOM Exception 11 while sending a blob through websocket up vote 1 down vote favorite 1 I'm trying to send through websockets a blob obtained through dataURItoBlob(canvas.get()[0].toDataURL('image/png')); in this way: connection.send(JSON.stringify({ cmd: "fwd", msg: msg, p_id: worker_id, }) where msg is the blob just created. If I try to send the blob by doing msg = ""+msg it works but it only sends the string [Object object], which is useless for me. If I try to do msg = JSON.stringify(msg) before sending it, it gives me the same error, as in the topic title. If I try to send the data without encapsulating it in a blob (as msg = canvas.get()[0].toDataURL('image/png'); ) I have the same behaviour explained above. What can I do to send the data? Thanks javascript html5 share|improve this question asked Oct 30 '12 at 11:11 Masiar 4,8532061101 Is the error caused by stringify or by send? –Teemu Ikonen Oct 30 '12 at 12:41 The error appears in send() –Masiar Oct 30 '12 at 13:06 add a comment| 1 Answer 1 active oldest votes up vote 4 down vote JSON.stringify() is perfectly OK and it is the way to do it. The "INVALID_STATE_ERR: DOM Exception 11" error is caused by executing send() message before the socket is connected. WebSocket.send() should be triggered after WebSocket.onopen() event handler was triggered (or inside of that handler): this.ws = new WebSocket("ws://localhost:1234", "base64"); this.ws.onopen = function() { this.send({"type":"init_req"});}; share|improve this answer edited Feb 6 '13 at 16:52 answered Feb 6 '13 at 15:53 RKI 1668 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged javascript html5 or ask your own question. asked 3 years ago viewed 1323
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up INVALID_STATE_ERR: DOM Exception 11 (WebKit) up vote 31 down vote favorite http://stackoverflow.com/questions/13137753/invalid-state-err-dom-exception-11-while-sending-a-blob-through-websocket 11 I recently tested a Cappuccino app I was working on with Chrome and Safari. I get the error: INVALID_STATE_ERR: DOM Exception 11: An attempt was made to use an object that is not, or is no longer, usable. The lack of information is frustrating. What object and where did I attempt to use it? Chrome tries to answer the second question but the line number it gives, 465, http://stackoverflow.com/questions/3488698/invalid-state-err-dom-exception-11-webkit doesn't mean anything when the file it gives is just 94 lines long. Without more information I don't even know where to start looking. javascript dom webkit cappuccino share|improve this question asked Aug 15 '10 at 18:35 Regis Frey 5151718 add a comment| 10 Answers 10 active oldest votes up vote 10 down vote accepted Chrome canary offers stack traces for DOM Exceptions! share|improve this answer answered Jun 16 '12 at 22:45 Jamie Pate 706712 1 This is the best answer to this question. Made my day. Thank you sir! –Nek Jun 25 '12 at 19:19 3 "DOM exceptions have stack trace in Chrome 21." code.google.com/p/chromium/issues/detail?id=64319 –Regis Frey Aug 17 '12 at 20:06 add a comment| up vote 52 down vote Usually this error occurs with the XMLHttpRequest when you call the open method with async = true, or you leave the async parameter undefined so it defaults to asynchronous, and then you access the status or responseText properties. Those properties are only available after you do a synchronous call, or on the readyState becoming ready (once the asynchronous call responds). I suggest you first try with async = false, and then switch to it being true and use the onReadyStateChange. share|improv
Sign in Pricing Blog Support Search GitHub This repository Watch 5 Star 154 Fork https://github.com/gregmuellegger/django-websocket/issues/2 30 gregmuellegger/django-websocket Code Issues 3 Pull requests 1 Projects 0 http://otiai10.hatenablog.com/entry/2013/06/21/191615 Pulse Graphs New issue Uncaught Error: INVALID_STATE_ERR: DOM Exception 11 #2 Closed joshdavey opened this Issue Jul 20, 2010 · 4 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 3 participants joshdavey dom exception commented Jul 20, 2010 I get this when trying to run the following javascript: var ws = new WebSocket("ws://api.burstn.dev/1/timeline/global"); ws.onopen = function(evt) { alert("Conn opened"); }; ws.onread = function(evt) { alert("Read: " + evt.data); }; ws.onclose = function(evt) { alert("Conn closed"); }; ws.send("Hello World"); api.burstn.dev is pointed to my virtual dom exception 11 machine where I'm running django with ./manage.py runserver (no multithreadeding -- see other issue). The method handling the request looks like this... @require_websocket def timeline_global(request): print request.is_websocket() if request.is_websocket(): print 'WEBSOCKETING' I am not using the middleware. The request is returning a 400 http status. joshdavey commented Jul 20, 2010 For the record I am using nginx. I just did some googling and found a few threads that suggested nginx doesn't support websockets. If anyone has any suggestions please let me know. joshdavey commented Jul 20, 2010 Yep, it was nginx afterall. I was able to use HAProxy to get around this though. Owner gregmuellegger commented Jul 20, 2010 Thanks for your investigation. I will include this into a new list of supported Webservers and not supporting webservers. Thank you very much!! davidfooks commented Jun 14, 2012 Might want to wait for the ws.onopen event before sending. See: http://stackoverflow.com/questions/3926152/websockets-issue-perhaps-same-origin-policy
限定公開記事のため引用できません。 読者です 読者をやめる 読者になる 読者になる DRYな備忘録 Don't Repeat Yourself. 2013-06-21 WebSocketのsend()でUncaught Error: InvalidStateError: DOM Exception 11 【WebSocket】【JavaScript】 【問題】 WebSocketでチャットアプリを(謎にPythonで)作ろうと思った。サーバサイドは問題なく動いて、サーバサイドでの websocket.send('Hi, this is Server!!') はクライアントのwebsocket.onmessageで取れてる。しかし、クライアント側のwebsocket.send('Hi, this is Client!!'); は、以下のエラーが出る。 Uncaught Error: InvalidStateError: DOM Exception 11 ( ´゚д゚`)エー 【コード】 クライアント側のコードはコレ $(function(){ socket = new WebSocket("ws://otiai10.com:9090/chat"); socket.onmessage = function(ev){ console.log('On Message Event =>', ev); } socket.send('Hi, this is Client!!'); }); // jquery使ってます 【調査】 特にこれ http://stackoverflow.com/questions/5265966/error-invalid-state-err-dom-exception-11-with-php-websockets えーブラウザのWebSocketが準拠しているドラフトと、サーバ側のドラフトが違うんじゃねえの疑惑。そんなんめんどくさいorz 【待てよ?】 ブラウザのコンソール onmessageイベントがsendよりも後に起きていることが分かる。まーソケットつながってサーバがメッセージ送ってくるのにタイムラグがあるのは当然だが、そういえばJSの一部メソッド、特に通信とかトランザクションって非同期でしたよね... 【解決】 JS変えた $(function(){ socket = new WebSocket("ws://otiai10.com:9090/chat"); socket.onmessage = function(ev){ console.log('On Message Event =>', ev); } // socketが開いてはじめて発動するイベントリスナー socket.onopen = function(ev){ console.log('On Open Event =>', ev); socket.