nicolasff / webdis

A Redis HTTP interface with JSON output
https://webd.is
BSD 2-Clause "Simplified" License
2.84k stars 304 forks source link

Websockets and subscribe - seems to close on open #58

Closed b1c9g76 closed 11 years ago

b1c9g76 commented 11 years ago

(NB: Newbie here)

I isue a SUBSCRIBE and I get back a subscribe reply as expected and then the websocket closes straight away. I was expecting it to stay up similarly to issuing the same SUBSCRIBE through a webbrowser where it stays open and recieves data as PUBLISH commands are issued.

What am I missing?

var jsonSocket = new WebSocket("ws://127.0.0.1:7379/.json"); jsonSocket.onopen = function() { console.log("JSON socket connected!"); jsonSocket.send(JSON.stringify(["SUBSCRIBE", "test"])); }; jsonSocket.onmessage = function(messageEvent) { console.log("JSON received:", messageEvent.data); }; jsonSocket.onclose = function() { console.log("JSON closed"); };

Console output:

JSON socket connected! test.html:55 JSON received: {"SUBSCRIBE":["subscribe","test",1]} test.html:60 JSON closed

dcosta72 commented 11 years ago

I've just pushed a fix for that in my forked repository. See issue https://github.com/nicolasff/webdis/pull/59 with my pull request.

nicolasff commented 11 years ago

Closing as duplicate of #59.