0

I have been trying to implement websockets in a laravel 8 API but all in vain. I have tried using this package but whenever i try to connect , it returns a 404 not found.

I am wondering if there is a specific way of building and testing the implementation of websockets in laravel. Any help would be greately appreciated

kamasuPaul
  • 173
  • 1
  • 9

1 Answers1

0

How do you connect with your websockets? If the server's host is different than your frontend, you should configure that in the websocket connection.

If you use Laravel Echo, change the authEndpoint:

new Echo(
    broadcaster: 'pusher', // The broadcaster you're using
    key: pusherKey, // The key of the broadcaster
    wsHost: localhost, // The host of the websocket server
    wsPort: 6001, // The port of the websocket server
    authEndpoint: http://localhost:8000/broadcasting/auth, // The endpoint for authorization
    disableStats: true, // Disable sending stats to broadcast service
    enabledTransports: ['ws', 'wss'], // The enabled transports (this will only use websockets. if you don't add this, it could fall back to xhr-streaming or polling)
);
Sjoertjuh
  • 1
  • 2
  • Hey, @Sjoertjuh thanks for the answer but what am trying to avoid is using laravel echo, since echo seems to be a frontend package, yet I am implementing the web socket api, server side – kamasuPaul Nov 03 '21 at 06:31