Open swarajcs opened 8 years ago
Its not connecting ...
Am connecting to a websocket
var net = require('net'); var http = require('http');
http.globalAgent.maxSockets = 1000; var server_port = 4000;
function policy() { var xml = '<?xml version="1.0"?>\n<!DOCTYPE cross-domain-policy SYSTEM' + '"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">\n\n'; xml += '\n'; xml += '\n\0' ; return xml; }
console.log("server started");
//var WebSocketServer = require('/root/node_modules/ws').Server var WebSocketServer = require('ws').Server , wss = new WebSocketServer({ port: server_port });
wss.on('connection', function connection(ws) {
console.log("connection established"); ws.on('message', function incoming(message) { console.log(message); if(message == '<policy-file-request/>\0') { var x = policy(); ws.send(x); return; } }); ws.on('close', function() { }); ws.on('error', function() { });
});
what could be the issue?
Hi, did you test with https://www.piesocket.com/websocket-tester
I did, and it works very well....
Its not connecting ...
Am connecting to a websocket
var net = require('net'); var http = require('http');
http.globalAgent.maxSockets = 1000; var server_port = 4000;
function policy() { var xml = '<?xml version="1.0"?>\n<!DOCTYPE cross-domain-policy SYSTEM' + '"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">\n\n';
xml += ' \n';
xml += ' \n\0' ;
return xml;
}
console.log("server started");
//var WebSocketServer = require('/root/node_modules/ws').Server
var WebSocketServer = require('ws').Server , wss = new WebSocketServer({ port: server_port });
wss.on('connection', function connection(ws) {
});
what could be the issue?