问题
I am getting this error:
DOM Invalidate exception 11
From following code but I cannot find the cause.
/*This is little bit pseudo stylish coded so might have some
syntax errors */
var socket;
var client = {
connect: function(){
socket = new WebSocket(mylocation);
socket.onopen = this.open;
socket.send = this.send;
},
open: function(){
this.send("Sent from socket open function"); //works
socket.send("Sent from socket open function"); //works
},
_send: function(){
socket.send("Sent from send function"); //error
this.send("Sent from send function"); //error
}
}
client.connect();
client._send();
----- ERROR DESCRIPTION --------
//DOMException {message: "InvalidStateError: DOM Exception 11",
//name: "InvalidStateError", code: 11
I am currently using Java Jetty Websocket for the server. What does this error mean?
回答1:
Here you have infinite recursive function:
send: function(){
socket.send("Sent from send function"); //error
this.send("Sent from send function"); //error <--
}
回答2:
From my experience, this error typically means the server is busy / or that existing websocket connections are blocking, and are not allowing new websocket connections. I'm not familiar with Jetty, but I get the same error with a server consisting of uWSGI+gevent -- which allows at most one websocket connection at any given time -- when a second browser tries to connect before the existing connection is closed, it gets precisely this error.
来源:https://stackoverflow.com/questions/15088388/receiving-invalidstateerror-dom-exception-11-during-websocket-send