WS server doesn't work for me
andtsarenko opened this issue · 2 comments
andtsarenko commented
Here is client code, that I've run on my PC
var url = 'ws://10.0.21.222:3004';
var socket = new WebSocket(url);
socket.onopen = function() {
console.info("opened");
};
socket.onclose = function(event) {
if (event.wasClean) {
console.info('closed');
} else {
console.info('dirty closed');
}
};
socket.onmessage = function(event) {
console.info("data" + event.data);
};
socket.onerror = function(error) {
console.info("error " + error.message);
};
Here is code that I'm running in cordova app on android:
wsserver.start(3004, {
// WebSocket Server handlers
'onFailure' : function(addr, port, reason) {
console.log('Stopped listening on %s:%d. Reason: %s', addr, port, reason);
},
// Other options
'origins' : [ 'file://' ], // validates the 'Origin' HTTP Header.
'protocols' : [ 'my-protocol-v1', 'my-protocol-v2' ], // validates the 'Sec-WebSocket-Protocol' HTTP Header.
'tcpNoDelay' : true // enable/disable Nagle's algorithm. false by default.
}, function onStart(addr, port) {
console.log('Listening on %s:%d', addr, port, arguments);
}, function onDidNotStart(reason) {
console.log('Did not start. Reason: %s', reason);
});
IP of my mobile device is 10.0.21.222
on mobile device (WS server) the only console message that I retrieve is:
Listening on :::3004
On my client im retriving nothing but closing event with err code 1006
Mobile device Nexus 6p android 7.1.1
Cordova v6.5.0
becvert commented
Please remove the 'other options' if you don't understand or don't need them.
And please close this issue when it's working. Thank you.
375683067 commented
Thanks for you reply.