[Vuejs]-Vue Websockets double

3👍

Your Echo is attached to window, Vue is not reloading page, it’s just switching it with JS, so your connection stills alive.

You should disconnect before leaving page, so just do it in beforeDestroy hook. More about hooks here

Also if you need this connection everywhere you should not initialize it in mounted, created or elsewhere in Vue component, you can just create separate file or plugin for Vue, because that function will trigger each time you opening page.

Leave a comment