I'm using Redis + Webdis on Debian 7 32.
My issue is that all websocket connections are closed with the exit code 1006 after pleting the first mand (except the "SUBSCRIBE" one). For example, for this testJSON() function
function testJSON() {
var jsonSocket = new WebSocket("ws://ip:7379/.json");
jsonSocket.onopen = function() {
console.log("JSON socket connected!");
jsonSocket.send(JSON.stringify(["SET", "hello", "world"]));
jsonSocket.send(JSON.stringify(["GET", "hello"]));
};
jsonSocket.onmessage = function(messageEvent) {
console.log("JSON received:", messageEvent.data);
};
jsonSocket.onclose = function(messageEvent) {
//some logging
};
jsonSocket.onerror = function(messageEvent) {
//some logging
};
}
testJSON();
i'm getting (in Firebug)
JSON socket connected!
JSON received: {"SET":[true,"OK"]}
onClose: error.code 1006
The onError event is'nt working, and after the {"SET":[true,"OK"]} response my connection closes. GET mand is'nt working too. Same behavior in Firefox and Chrome. I checked the headers, it seems they are valid.
Any suggestions?
I'm using Redis + Webdis on Debian 7 32.
My issue is that all websocket connections are closed with the exit code 1006 after pleting the first mand (except the "SUBSCRIBE" one). For example, for this testJSON() function
function testJSON() {
var jsonSocket = new WebSocket("ws://ip:7379/.json");
jsonSocket.onopen = function() {
console.log("JSON socket connected!");
jsonSocket.send(JSON.stringify(["SET", "hello", "world"]));
jsonSocket.send(JSON.stringify(["GET", "hello"]));
};
jsonSocket.onmessage = function(messageEvent) {
console.log("JSON received:", messageEvent.data);
};
jsonSocket.onclose = function(messageEvent) {
//some logging
};
jsonSocket.onerror = function(messageEvent) {
//some logging
};
}
testJSON();
i'm getting (in Firebug)
JSON socket connected!
JSON received: {"SET":[true,"OK"]}
onClose: error.code 1006
The onError event is'nt working, and after the {"SET":[true,"OK"]} response my connection closes. GET mand is'nt working too. Same behavior in Firefox and Chrome. I checked the headers, it seems they are valid.
Any suggestions?
Share Improve this question edited Jul 23, 2016 at 22:36 Paul 27.5k13 gold badges89 silver badges126 bronze badges asked Mar 25, 2014 at 20:42 Andrew RooAndrew Roo 611 gold badge2 silver badges5 bronze badges 2- 1 1006 is a special code that means the connection was closed abnormally (locally) by the browser implementation. I tried your example and changed server to ws://echo.websocket it seems to be working fine. Whats the version of your browser? can you try to connect to echo.websocket and chk whether you still get disconnected. – Jack Daniel's Commented Mar 26, 2014 at 8:35
- Hi. TY, connection to ws://echo.websocket works well, without any problems. I had some suggestions about incorrect server responses, but it seems that webdis cannot log websocket actions. I use FF 27.0.1 – Andrew Roo Commented Mar 26, 2014 at 9:35
1 Answer
Reset to default 3Ok, it's a feature, not bug. In code (websocket.c):
if (cmd_is_subscribe(cmd)) {
r->keep_alive = 1;
}
Changing this code solved part of my problems, but not all of them.