使用Node JS + Einaros WS Server当我启动服务器并在浏览器上打开http:// serverIp:port时,我得到一个“Not Implemented
”
模块文件WebSocketServer.js
文件如下所示:
if (options.isDefinedAndNonNull('port')) {
this._server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Not implemented');
});
this._server.listen(options.value.port, options.value.host, callback);
this._closeServer = function() { self._server.close(); };
}
不是发送此Not implemented
消息,而是如何模拟不可用或页面不存在?我不想客户端找出真正的serverIp / Port,因为它实际上是在haProxy负载均衡器后面工作。
答案 0 :(得分:1)
我想到了以下两个选项:
最好的选择很可能是阻止除了haProxy以外的其他人与您的防火墙的连接。
如果不可能,我会用res.socket.destroy()
关闭底层套接字,使客户端认为该服务器不理解协议。
<强>更新强>
更改此
this._server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Not implemented');
});
到这个
this._server = http.createServer(function (req, res) {
res.socket.destroy();
});
它应该有用。