-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't disconnect from Pusher #94
Comments
You can use ".leave()" method which is described in the doc |
But that's not the same. You only leave a channel with this, which still keeps the Pusher connection open, I saw. Only pusher.disconnect() will close it, which is not available through Echo. |
@elasticsteve It would be really useful if you could give your use case as example. |
I said it in my first comment: to disconnect users keeping their tabs open. It's a common problem with Pusher, because it eats up all your available connections and you max out. |
@elasticsteve I mean, could you write some pseudo code implementation of that. How would you use .disconnect() if it were implemented. Will you need .reconnect() ?
Whats your opinion on this? |
You open a connection with new Echo(); At that moment Pusher shows an active connection, even if there is no listener subscribed. We need something to close that connection again, so Pusher releases the connection. On my account I have a max of 200 connections, but if people just leave their tabs open on a computer that is on all day or at work, I run out of connection within hours. Pusher doesn't disconnect. Even worse if one user has my app on tabs, they eat up 4 connections! You can see how soon you run out. I think Echo. disconnect(); would be brilliant for that, similar to pusher.disconnect() |
Ok Im going to show you how I use Echo with ReactJS for my app and why I'm concerned about adding .disconnect() wouldn't be that easy as it seems:
So what I have to do with my shared Echo instance when user comes back to the tab? I think I want to call .reconnect() on my instance i guess? Then I need to resubscribe to all channels I have in this instance? |
I would't use it like this this. It's too extreme. I would use a timer tracking long inactivity. Of course the problem is that mobile phones just stop javascript when the tab is not active or the browser hidden. I heard there are new way, but I'm not familiar with it. There whole thing became such a nightmare for me that I actually don't use Pusher / Echo now. It's not essential for my app, but it would have been nice for some real time updates and messages. Since they are not essential for my app, it's not worth doing right now, because I would run out of max connections all the time and it would ruin everything. Unless we find a better way of dealing with inactive user tabs or even hidden browsers, I can't really see Pusher going very far in terms of mainstream, where the real time websocket updates are not a "must", but rather an expensive pain in the neck. |
@elasticsteve thanks for sharing your experience tho. I think that disconnect should be added after all but I want someone from echo team to share their thoughts on its implementation first. |
I guess you could try to call .disconnect() on it. |
Thanks, I will. How would I re-connect again? |
@elasticsteve at this point I guess there is nothing better than call |
ok, just wanted to be sure it's the right thing to do. |
@elasticsteve I have added the disconnect functionality inside my pull request. Hope it helps |
Great! |
@elasticsteve Pull request just got merged. Could you please test it and let me know if it works for you. |
@maxpaynestory Sorry, I'm not using Pusher anymore in the app I'm developing. We will need it later (in a few months again) for new features. |
then i guess this issue can be closed? |
@maxpaynestory Hey -- just wanted to say he may have not used this but I really appreciate your adding it! We have an app where a user can be part of multiple companies, so when they switch companies we need to completely disconnect them from the other company's pusher channel and resub. This saved the day. |
@maxpaynestory actually, I may have spoken too soon :) I'm not seeing the disconnect method in the suggestions nor is it disconnecting from Pusher. If you have any ideas, let me know! Edit: Nope, I did not, it works exactly as expected. Just had some cached code or something. Thank you! |
Pusher has the disconnect() method. Is there such a thing in Echo? I couldn't see it. It's very important for me to disconnect users who keep their tab(s) open otherwise I run out of connections.
The text was updated successfully, but these errors were encountered: