Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Laravel Echo will still connect to Pusher as fallback #19

Closed
bhulsman opened this issue Dec 5, 2018 · 2 comments
Closed

Laravel Echo will still connect to Pusher as fallback #19

bhulsman opened this issue Dec 5, 2018 · 2 comments

Comments

@bhulsman
Copy link

bhulsman commented Dec 5, 2018

When connection fails, it will still try and connect to Pusher (over XHR) as a fallback.

More specifically to http://sockjs.pusher.com/pusher/app/.... Did I forget to change something in my config/echo/etc. files or is this expected behavior for now?

@mpociot
Copy link
Member

mpociot commented Dec 5, 2018

Yeah, that's how the Pusher JS client handles this.
By default it will try to connect via WebSocket and will fallback to use polling XHR requests.
You can disable this by forcing the pusher client to only use websocket connections like this:

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    wsHost: window.location.hostname,
    wsPort: 6001,
    disableStats: true,
    enabledTransports: ['ws', 'wss'] // <-- only use ws and wss as valid transports
});

@mpociot mpociot closed this as completed Dec 5, 2018
@gcw07
Copy link

gcw07 commented Dec 6, 2018

This would be great to add to the documentation. Thanks for the fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants