socket.io - can't get it to work, having 404's on some kind of polling call

后端 未结 3 1732
闹比i
闹比i 2020-12-08 13:20

I\'m trying to get a server set up with socket.io, with bad results.

I am mostly following this guide, although it\'s somewhat out of date: http://www.williammora.co

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 13:55

    In my case, I created my app with the Express application generator. To solve this problem, instead of edit the app.js file on the root folder of the project, I edited the file bin/www on the line after the server is defined:

    /**
     * Create HTTP server.
     */
    
    var server = http.createServer(app);
    var io = require('socket.io')(server); // Add this here
    

    Update

    I found a better way here Express Generator and Socket.io

提交回复
热议问题