-
Notifications
You must be signed in to change notification settings - Fork 370
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
Pusher Presence Channnel: Get notified when client gets disconnected from internet using webhook. #59
Comments
Hi, It's generally impossible for the server to detect whether someone closed a tab or got disconnected from the Internet, so you can't get that information from a presence channel. It is possible to send a message if someone voluntarily unsubscribes, but in general case it's very difficult to find reasons why clients leave channels. |
Thanks for the clarification. Can you please explain then how channel.members method work? This is the scenario we wanted to handle. We've android tablet devices subscribed to a certain channel. We have a web server which wanted to report which all devices are connected or online now. The devices can go offline because of multiple reasons such as:
Can you please let us know whether the above can be handled by Presence channel? If not is there any other suggestion for the same? Other option we could think of is polling, I.e. Device sending the heartbeat at frequent intervals. But is there any other suggestion? Thanks, |
Hi Leena, Presence channels will handle all your scenarios. There are different ways a client can get disconnected from Pusher:
In scenarios 1 and 2, the server knows immediately about disconnection and will remove the member from the presence channel. In scenario 3, there will be a delay, because the server has to send a ping message to check if the client is alive. If the client doesn't respond, the server closes the connection and removes the member from the presence channel. Do you want to use presence channels just for the server or do you want clients to do something with it too? The problem is that presence channels are meant to provide a member list for clients and on every join/leave they notify all clients about that fact. This means that huge channels generate a lot of traffic, so are very expensive and we advice to keep their size limited. If it's just the server that needs to store the list of clients, presence channels are not the best choice, I'm afraid. Polling might work better for you, but it has got its disadvantages, such as latency. It would be best if clients could opt out of receiving notifications from presence channels, but we don't support it at the time being. |
Thanks for the detailed explanation Paweł. It was really useful. As suggested, we will go ahead with polling implementation. Latency may not be a big problem for us as even a minute or two delay also would be fine in our case. |
Thanks, no problem. I'm closing the issue, if there is anything more you'd like to know, feel free to re-open it :) |
Thanks Paweł |
I have been working with pusher channels and am stuck with the following problem:
Using presence channels in Pusher (http://pusher.com), I can get notified in the server side when someone connects or disconnects from a presence channel, but how can I get notified when client gets disconnected from the internet?
The text was updated successfully, but these errors were encountered: