Where is my client side socket.io?

后端 未结 1 546
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-27 15:31

I have created an isomorphic React app using Express and React-Engine. Right now I am trying to connect socket.io. In the express setup I have

var express = requ         


        
相关标签:
1条回答
  • 2021-01-27 16:25

    The sequence I am using that works is this:

    var express = require('express');
    var app = express();
    var server = app.listen(8081);
    var io = require('socket.io').listen(server);
    

    I'm not sure exactly which aspect of yours might be causing the problem, but it's different than this, particularly in how you set up the server (you assign two different values to your server variable which does not seem right) and how you initialize socket.io.

    Also, I've seen some people with the client version of socket.io installed server-side, not the server version which obviously won't give you the ability to serve the /socket.io/socket.io.js file so that's worth checking.

    0 讨论(0)
提交回复
热议问题