Socket.io 404 error

前端 未结 4 1637
心在旅途
心在旅途 2020-12-22 04:12

I have followed Jeffrey way\'s tutorial.
Tutorial:
https://laracasts.com/series/real-time-laravel-with-socket-io/episodes/1

this is my index.js



        
4条回答
  •  执念已碎
    2020-12-22 05:04

    I'm adding this because this comes up first on Google and it took me 2 days to find a solution.

    I'm using Node.js and React, with socket.io-client

    I was able to make it work by passing a url and a configuration object to the io namespace.

    import io from 'socket.io-client'
    const socket = io('http://localhost:3000', {
        reconnectionDelay: 1000,
        reconnection: true,
        reconnectionAttemps: 10,
        transports: ['websocket'],
        agent: false,
        upgrade: false,
        rejectUnauthorized: false
    });
    

提交回复
热议问题