1

Express-generator nodejs モジュール ( http://expressjs.com/starter/generator.htmlexpress ) のコマンドを使用して、単純なプロジェクト構造を作成しました。

アプリを起動すると、リクエストごとに 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 エラーを解決する方法について何かヘルプはありますか? 前もって感謝します。

4

1 に答える 1

0

Express-generator はソケットを認識しません。モジュール「socket.io」がインストールされておらず、サーバーがソケットをリッスンしていません。

解決策: http://socket.io/docs/ (公式ドキュメント)

ソケットは、WebSocket、XHR、HTTP などの多くのトランスポートを介して機能します。クライアントは利用可能なすべてのトランスポートを介して接続を試み、HTTP を介して応答を受信します。ただし、応答は「404」です。これは、リクエストが socket.io ではなく Express のルーターによって処理され、ルーターに適切なルートがないためです。

于 2015-08-26T08:37:33.053 に答える