I have this piece of code running on several devices without issue. But one device is having problems that is driving me insane.
The client device can connect to the websocket server and receives data but when I try and send data back, the server does not receive any data. The results are intermittent but most of the time get no response; however, I never lose my SSH connection to the client device. No error messages, I just see my client device receiving a request from the server then sending data but the server showing nothing. When I restart the client program, I get a response.
Code is dead simple:
Server:
socket.emit('get settings',data); //client receives this!
socket.on('load settings', function (data) {
console.log("load settings |",data.mac); //no response from client
device_socket.emit('loaded settings',data);
});
Client:
var relay = require('socket.io-client')("http://"+relay_server+":"+relay_port);
relay.on('get settings', function (data) {
relay.emit('load settings', settings); //server never gets this!
console.log("sending settings"); //this is reached without error
});
server code: https://github.com/physiii/open-automation/blob/master/relay/socket.js
client code: https://github.com/physiii/open-automation/blob/master/gateway/socket.js
via physiii
No comments:
Post a Comment