我在端口3030上运行快速Web应用程序,但它通过http-proxy代理。该网站以这种方式正常工作,但socket.io不会连接。它收到的东西作为我的控制台显示:NodeJS,http-proxy,socket.io
debug - served static content /socket.io.js
debug - client authorized
info - handshake authorized 11319742841450363586
debug - setting request GET /socket.io/1/websocket/11319742841450363586
debug - set heartbeat interval for client 11319742841450363586
debug - client authorized for
debug - websocket writing 1::
app.js
app.listen(3030)
io = require('socket.io')
socket = io.listen(app)
socket.on('connection', function(client) {
console.log('new connection')
})
chat.js
$(function() {
console.log('connecting to chat...')
var socket = io.connect('http://mydomain.com:80')
socket.on('connected',function(){
console.log('connected')
})
})
然而,无论是有史以来的console.log语句显示在客户端或服务器端。我究竟做错了什么?
编辑 - 添加HTTP代理代码
var httpProxy = require('http-proxy')
, proxyTable = {
router: {
'lou.mydomain.com': '127.0.0.1:3030'
, 'foe.mydomain.com': '127.0.0.1:3000'
// and some others
}
}
, proxyServer = httpProxy.createServer(proxyTable);
proxyServer.listen(80);
你应该粘贴您的HTTP代理配置 – 2012-01-02 10:01:17
@xsace的代码 - 我编辑的职位,包括HTTP代理脚本 – 2012-01-02 10:07:35
我遇到了同样的问题。你有没有想过它? – 2012-11-01 05:40:18