J
J
JustRoo2014-03-25 16:48:40
JavaScript
JustRoo, 2014-03-25 16:48:40

Why are websocket connections closed with code 1006?

Good afternoon.
I have the following configuration - Redis + Webdis on Debian 7 x32.
The problem is that after the first command is executed, all websocket connections are closed with code 1006. For example, we execute the following code:

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
    };
}
testJSON();

When executed, we get in firebug:
JSON socket connected!
JSON received: {"SET":[true,"OK"]}
onClose: error.code 1006
The onError event does not fire. Immediately after the response about the established SET, the connection is closed. The GET command, accordingly, no longer works. The subtlety is that if you do SUBSCRIBE, the connection remains open and works fine until the next command is executed.
Question: where to look for a catch?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JustRoo, 2014-03-31
@JustRoo

Turns out it's a feature, not a bug. In code (websocket.c):
if (cmd_is_subscribe(cmd)) {
r->keep_alive = 1;
}
Changing this parameter solved some of the problems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question