Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket immediately Closing again with protocol parameter #441

Open
joergs-git opened this issue Aug 10, 2017 · 3 comments
Open

Websocket immediately Closing again with protocol parameter #441

joergs-git opened this issue Aug 10, 2017 · 3 comments

Comments

@joergs-git
Copy link

joergs-git commented Aug 10, 2017

Hi, I am trying to use a code-device to access a external websocket server.
So entered one simple line of code as follows:

var ws = new sockets.websocket("ws://192.168.1.61:23456/","toptron-protocol"); ws.onopen = function() { ws.send ("ping"); setTimeout(10000); ws.send("set:LIGHT_OUT1=%%"); };

Basically a connection from the UI to the external websocket server is being successfully established, but it's immediately closed again, before able so send actual commands.
Maybe because of a missing ping? However my actual ws.send command or ws.send ping command is not even getting through, because the connection has already closed down again.

Is there a way to set a timeout or generate a ping in different ways to make this work?

@joergs-git
Copy link
Author

joergs-git commented Aug 10, 2017

@PoltoS :
I just got a little step further:
If I remove the protocol parameter suddenly it seems to work and connection stays alive.
Bad implementation of websocket details?

The following basically doesn't work, unless I remove the "toptron-protocol":

var sock = new sockets.websocket("ws://192.168.1.61:23456","toptron-protocol"); sock.onopen = function () {sock.send("set:LIGHT_OUT1=%%"); setTimeout('sock.close();',1000); };

(I don't know if I really need to manually close the socket, but this doesn't seem to be the problem in the moment. )

What I also found strange is, that (if I remove the protocol paramter) I am not really able to send subsequent websocket-messages without having wait for a disconnect first.
e.g.
var sock = new sockets.websocket("ws://192.168.1.61:23456");} sock.send("set:LIGHT_OUT1=%%");

Results in a websocket-debugging-log like this:

> user@raspberrypi3-jkl1:~# wscat -l 23456 -p toptron-protocol
listening on port 23456 (press CTRL+C to quit)
client connected
< set:LIGHT_OUT1=0
disconnected
client connected
< set:LIGHT_OUT1=99
disconnected
client connected
< set:LIGHT_OUT1=0
disconnected
client connected
< set:LIGHT_OUT1=1
disconnected
client connected
disconnected

@joergs-git joergs-git changed the title Websocket immediately Closing again Websocket immediately Closing again with protocol parameter Aug 10, 2017
@joergs-git
Copy link
Author

see also detailed steps to reproduce this problem here:
http://forum.z-wave.me/viewtopic.php?f=3419&t=22347&start=30#p69949

@mforss
Copy link

mforss commented Oct 4, 2018

@PoltoS, I installed the debian package version 2.3.8-rc8 on stretch but the issue still exists.

You may be aware of this since this issue is still open. However, according to the following release notes it should work:
"- Added libraries for Raspbian Stretch"
"- Fixed socket not being closed on peer disconnect"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants