Yes, I need to recieve info from external websocket server.
What kind of module do you mean? Can you point to some recources that I could start?
Websocket Support in 2.0
Re: Websocket Support in 2.0
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test
Re: Websocket Support in 2.0
You have two options:
1) write websocket client in pure JS using TCP socket, but you'll have troubles handling https.
2) use some C/C++ wesocket library and wrap it into native module (there's an example published, see pinned topic)
1) write websocket client in pure JS using TCP socket, but you'll have troubles handling https.
2) use some C/C++ wesocket library and wrap it into native module (there's an example published, see pinned topic)
Re: Websocket Support in 2.0
Thank you, pofs
I found the topic viewtopic.php?f=3422&t=21409 (it's not pinned though)
Is there any additional info about sockets object except viewtopic.php?f=3424&t=20849&p=55058&hi ... ets#p55058
How can I receive info via TCP in engine (only 'send' described in your message)?
I found the topic viewtopic.php?f=3422&t=21409 (it's not pinned though)
Is there any additional info about sockets object except viewtopic.php?f=3424&t=20849&p=55058&hi ... ets#p55058
How can I receive info via TCP in engine (only 'send' described in your message)?
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test
Re: Websocket Support in 2.0
Strange, it was there when I looked for the last time. Think it just expired, so I pinned it back
There's an example of both TCP client and echo server in 2.0 developer documentation, you can pick it on github.
There's an example of both TCP client and echo server in 2.0 developer documentation, you can pick it on github.
Re: Websocket Support in 2.0
I used 2.0 version of developer documentation, but there is a new one 2.0.1 with additional function described.
Thank you pofs for pointing me.
So now I can use TCP connection to emit events from IR remote control.
Thank you pofs for pointing me.
So now I can use TCP connection to emit events from IR remote control.
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test
Re: Websocket Support in 2.0
pofs, could you help with TCP issue?
I tested sending and recieving with TCP seems OK. But onconnect(), onclose() are called only for listening sockets. For client connection there are no events fired on connection or on close, and when then I try to send on closed connection the z-way-server proccess is terminated.
I tested sending and recieving with TCP seems OK. But onconnect(), onclose() are called only for listening sockets. For client connection there are no events fired on connection or on close, and when then I try to send on closed connection the z-way-server proccess is terminated.
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test
Re: Websocket Support in 2.0
I believe onclose() should be called for connected socket as well (either if the connection is terminated by server or close() is called on the socket).dolpheen wrote:pofs, could you help with TCP issue?
I tested sending and recieving with TCP seems OK. But onconnect(), onclose() are called only for listening sockets. For client connection there are no events fired on connection or on close, and when then I try to send on closed connection the z-way-server proccess is terminated.
onconnect() is really called only for listening sockets, for connected you just check the status returned by connect() function. If it returns true, the connection was successful.
I'll look into crash reasons. Can you please provide some code to reproduce the issue, so it would be easier to fix it?
Re: Websocket Support in 2.0
Thanks for pointing me, pofs. That's was my fault . I tested with simple JS and netcat and everything looks OK as you described.
The problem was that I made 'send' requests in a handler on event emit and if I reload the module without unsubscribing from this event and subscribe to a new one on next module restart there was a crash.
There is another question - if socket is closed I cannot connect to it again and have
The sample code is below
The problem was that I made 'send' requests in a handler on event emit and if I reload the module without unsubscribing from this event and subscribe to a new one on next module restart there was a crash.
There is another question - if socket is closed I cannot connect to it again and have
Code: Select all
[E] [core] Callback execution error: Error: Socket is already connected
at Error (native)
at tcp.sock.onclose (automation/tcp-sock-test.js:10:8)
Code: Select all
var sock = new sockets.tcp();
sock.onclose = function (){
console.log('Closed!!!!!!!');
// There we have the error that socket is already connected
sock.connect('192.168.10.98', 8765);
};
sock.connect('192.168.10.98', 8765);
sock.send('SEND_ONCE vixter KEY_1\n');
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test