2015-08-16 19 views
1

我使用express命令從express-generator nodejs模塊(http://expressjs.com/starter/generator.html)創建了一個簡單的項目結構。在某種輪詢上使用404 - 使用快速生成器的新nodejs項目

當我啓動應用程序,一切都很好,除了一個奇怪的輪詢呼叫它得到404爲每個請求:

Listening on port 3000 
GET/200 533.444 ms - 170 
GET /stylesheets/style.css 200 4.643 ms - 111 
GET /socket.io/?EIO=3&transport=polling&t=1439686799050-244 404 40.935 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686802114-245 404 27.494 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686806157-246 404 16.291 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686811211-247 404 12.629 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686816239-248 404 20.037 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686821276-249 404 13.513 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686826320-250 404 16.412 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686831383-251 404 10.820 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686836420-252 404 11.827 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686841478-253 404 15.267 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686846669-254 404 12.168 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686851754-255 404 11.569 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686856976-256 404 8.629 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686862211-257 404 6.490 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686867255-258 404 8.431 ms - 1235 
GET /socket.io/?EIO=3&transport=polling&t=1439686872285-259 404 14.600 ms - 1235 

如何解決404錯誤任何幫助嗎?提前致謝。

回答

0

快速發生器不知道套接字。您未安裝模塊'socket.io',並且您的服務器不在偵聽套接字。

解決方案:WebSockets的,XHR,HTTP等:http://socket.io/docs/(官方文檔)

套接字可以通過多種運輸工作。客戶端嘗試通過所有可用的傳輸進行連接,並通過HTTP接收響應。但是響應是「404」,因爲請求由Express的路由器處理,而不是由socket.io處理,並且路由器沒有合適的路由。