websocket client

Discussions about Z-Way software and Z-Wave technology in general
klaasjoerg
Posts: 126
Joined: 30 Sep 2016 23:49

Re: websocket client

Post by klaasjoerg »

Hi PoltoS, I sent you a PM with some further informations...
klaasjoerg
Posts: 126
Joined: 30 Sep 2016 23:49

Re: websocket client

Post by klaasjoerg »

Hi PoltoS, as already sent via PM here some further details how to reproduce the websocket protocol issue.
By the way: The login ssl problem (see viewtopic.php?f=3419&t=25251#p69852) seems to be somehow related to websocket issues too...

Step 1. Install wscat as a simple websocket service on a raspberry (e.g. https://www.npmjs.com/package/wscat)

Code: Select all

npm install -g wscat
and start a simple websocket listener server with this command (e.g. Port 9000 and protocol type toptron-protocol, but doesn't matter actually for now):

Code: Select all

wscat -l 9000 -p toptron-protocol
then you should see a console prompt like this:

Code: Select all

root@raspberrypi3-jkl1:/opt# wscat -l 9000 -p toptron-protocol
listening on port 9000 (press CTRL+C to quit)
next

Step 2. setup a little JS-zwave-App as a websocket-client, with the following sample code:

Code: Select all

// establish a new websocket connection to websocket server
var knausock = new sockets.websocket ("ws://192.168.1.61:9000","default");

// debug/pring incoming websocket messages, if available
knausock.onmessage = function (knausval) {
   var received_msg = knausval.data;
   debugPrint ("Socket-MSG-Received: ",received_msg);
}
zwave-ui-JS-websocket-app
zwave-ui-JS-websocket-app
ss 1.png (193 KiB) Viewed 5759 times
Step 3.
Now activate the little JS-App and you should see a successful connection in the console prompt

Code: Select all

root@raspberrypi3-jkl1:/opt# wscat -l 9000 -p toptron-protocol
listening on port 9000 (press CTRL+C to quit)
client connected
> 
Step 4.
You can enter something here (e.g. MickyMouse) and should also see it as a debug output in the zwave-log too.

Code: Select all

[2017-08-13 13:04:49.877] [I] [core] Socket-MSG-Received:  mickymouse
So far so good. No problem 'till here.

Step 5.
Now disable the JS-App in UI again and simply change the zwave-JS-App slightly by entering a different protocol type, instead of "default".
e.g.

Code: Select all

var knausock = new sockets.websocket ("ws://192.168.1.61:9000","toptron-protocol");
zwave-ui-js-app deactivated
zwave-ui-js-app deactivated
ss 2.png (20.11 KiB) Viewed 5759 times

Step 6. Stop wscat and start it again to have a clean starting point again.

Step 7. Now enable the JS-App in the UI again and you should see that connection is immediately being disconnected again:

Code: Select all

root@raspberrypi3-jkl1:/opt# wscat -l 9000 -p toptron-protocol
listening on port 9000 (press CTRL+C to quit)
client connected
disconnected
In my opinion the zwave-websocket part is disconnecting it's own connection again just becaus it's not "default"-protocol, which shouldn't happen.
(The disconnection is not being initiated by the wscat server.). If you also want to quickly test this, you could simply use wscat to connect to it's other process by entering ( e.g. wscat -c 192.168.1.61:9000 and playing around a bit).

Additionally, if you logout now from UI and try to immediately login again, you will see the login issue effect as written in the other thread:
viewtopic.php?f=3419&t=25251#p69852
No login possible anymore until you restart zway again.

Hope this helps solving the two issues? Would be great!
Joerg
User avatar
PoltoS
Posts: 7571
Joined: 26 Jan 2011 19:36

Re: websocket client

Post by PoltoS »

hm.. tested on v2.3.5-rc17-internal and everything worked. According to git there is no difference in modules/socket...
klaasjoerg
Posts: 126
Joined: 30 Sep 2016 23:49

Re: websocket client

Post by klaasjoerg »

I installed a complete new, fresh re-installation unter newest jessie raspian and zwave 2.3.5. with the same behaviour.
Additionally I noticed, that if websocket connections disconnect after some time, that the "re-login issue" (see other thread) is occuring....
So currently I simply have to restart zwave everytime I want to login (if a websocket disconnect happened earlier)...
Post Reply