Show continuous connection message in nodejs socket.io

后端 未结 2 1073
Happy的楠姐
Happy的楠姐 2020-12-21 13:24

I am trying to develop a live chat application using laravel. I face a problem. When I run \"node index.js\" , \'A connection has made\' message has shown continuously in co

相关标签:
2条回答
  • 2020-12-21 13:40

    The usual reason that your client is continually trying to connect over and over again is because you have a mismatched client and server version of socket.io making them incompatible. You don't show how you load the socket.io Javascript in your web page, but if you do it like this:

    <script src="/socket.io/socket.io.js"></script>
    

    Then, you will always get the version that exactly matches your server from your server automatically (this is a route that the socket.io server automatically adds to your Express server).

    If you are loading socket.io from a CDN, then you have to either switch to the above to load it from your own server or manually specify the exact same version from the CDN as you are running on the server.

    0 讨论(0)
  • 2020-12-21 13:44

    Change port number from 3000 to 7000 for example.

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