Search code examples
node.jslaravelsocket.iolaravel-5.4laravel-echo

Laravel echo server console says left the channel and again joins the channel while navigating through pages?


I am trying to add realtime functionality to my laravel app which is being developed in laravel-5.4. So, I have implemented a simple chat example from the documentation that is laravel-echo-server with redis and socket.io. It’s working fine but I have noticed a weird behaviour that is when the user navigates to different pages across the application, the laravel-echo-server console says left the channel and again joined the channel so is it intended behaviour and what is the best practise to use it. am i doing something wrong here? I don't want him to left the channel, instead I want to stay him at the same connection.


Solution

  • If you change page, everything is lost and a new content is dowloaded from the server. So it's normal that the user "left the channel" then re"joined the channel". It's the intended behavior.

    If you don't want this kind of behavior, you have to stay one the same page (so implementing something like a single page application). Because when you leave a page to go to another, current scripts stops then a new world is re-created.