2014-05-02 24 views
0

所以我有一個小型的node.js和socket.io腳本從我讀過的教程中運行,但我遇到了一些問題。 該腳本似乎正在工作100%。 在Socket.io,而言,當我使用本地主機從客戶機到服務器的連接:Node.js和Socket.io適用於除我以外的所有人(主持人)

var socketio = io.connect("127.0.0.1:80"); 

它,工作正常,但是當我這樣做用我的公網IP地址(相關端口是開放的)有是一個問題,它不能連接我,但它連接任何查看我的腳本的人。頁面加載但沒有套接字腳本發生。 我的控制檯日誌中這樣的:

debug - xhr-polling writing 8:: 
    debug - set close timeout for client rV_r1hWJZ7gGA5ZtGCYY 
    debug - xhr-polling closed due to exceeded duration 
    debug - setting request GET /socket.io/1/xhr-polling/rV_r1hWJZ7gGA5ZtGCYY?t=1 
399020968259 
    debug - setting poll timeout 
    debug - discarding transport 
    debug - cleared close timeout for client rV_r1hWJZ7gGA5ZtGCYY 
    debug - setting request GET /socket.io/1/jsonp-polling/rV_r1hWJZ7gGA5ZtGCYY?t 
=1399020855254&i=0 
    debug - setting poll timeout 
    debug - discarding transport 
    debug - clearing poll timeout 

什麼可能發生在這裏是造成它工作的每一個人,除了我?

回答

1

確保你已經包括在socket.io你的腳本標籤是這樣的:

,然後你做

<script type="text/javascript"> 
    var socket = io.connect('http://yourPublicIP:port'); 
</script> 
+0

您好,感謝您的答覆,然而,問題依然仍然存在。 – Matthew

+0

我測試過它,它適用於我,我認爲你有一些網絡問題或類似的東西。如果您可以在此發佈服務器和客戶端代碼,那麼它將更有可能幫助您。 –

+0

在我的VPS上運行它可能會導致網絡問題。謝謝你的一切。 – Matthew

相關問題