我在端口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