Report back on connect/disconnect#26
Report back on connect/disconnect#26paulstatezny wants to merge 1 commit intomobileoverlord:masterfrom paulstatezny:report-back-connect-and-disconnect
Conversation
|
Hi! Our use-case was similar than yours, when the channel disconnects I want them to reconnect again, but I know that it's not needed to reconnect always, that's why in #25 it just closes the process and your process receives that event too, so you can handle it like you want (reconnect, or stop everything, log it to some reporting platform, ...) We've been using the code of the PR for weeks on production, and it seems to be working correctly, and also we don't see |
| {:ok, socket} = Socket.start_link(config) | ||
| wait_for_socket(socket) | ||
| assert_received {:phoenix_client, :connected} | ||
| end |
There was a problem hiding this comment.
I tried many ways of testing the :disconnected message, but there's some complicated OTP stuff going on here and it interacts with (and breaks) the other tests even though async is false. 😭
|
Ok, now I understand this PR, and it's different than #25 Edit: I'm thinking if maybe it makes sense to use the |
|
@rockneurotiko Yeah, my initial idea was using the caller pid. But I didn't like that that would force the caller to implement Perhaps a better model would be a boolean: Or something like that. And it would send to the caller. |
|
Nice! First, thank you Justin for this sweet library! Second, thanks, @paulstatezny, for this PR. It seems to be exactly what we need. Once reconnected after dropping, the socket is no longer subscribed to the channels as originally joined, so I would need to rejoin them. The problem is, there doesn't seem to be any feedback as to when to do this! I thought I was missing something until I found this PR... Is something like this going to be the best way to get the channels rejoined, or could it possibly be a reasonable idea for the library to automatically rejoin the channels? Cheers & Thanks! |
|
Thanks for chiming in @djthread! Some thoughts about the auto-join vs specify-pid vs send-to-caller options:
|
|
That all sounds good to me. I will probably soon be trying to make use of your branch, so thanks for contributing it! |
|
Turns out I was wrong here:
🤦♂ See: https://github.com/phoenixframework/phoenix/blob/master/assets/js/phoenix.js#L383 So I'm rethinking this. Rather than reporting back, I think the library should auto-rejoin on reconnect. @mobileoverlord How do you feel about that? I'd be glad to put in a PR. |
|
You are totally right! I thought too that it doesn't make the re-join! But they even say it on the documentation:
I will change my PR to do it, but it will still send the message up, just like on the javascript client they call the callback, so the process that started it still have control over it. |
|
First of all, thanks for the work put into the library and this PR. I have to admit, I am a bit stunned by the fact that there seems to be no Phoenix channel client library for Elixir itself that handles the most important concern, a stable connection, properly. In my opinion, the inclusion of this PR is absolutely essential, as is the implementation of the correct channel re-join behaviour proposed in #25. I am currently rewriting an embedded device software with the biggest focus being a stable connection to the server. So far, it is using Sadly, at the moment, it seems like the relevant PRs here are in limbo? I can fork the repo and get a working version, sure, but I would be interested to learn what keeps this library from moving forward at the moment? |
|
Closing this because it's probably never going to be merged. |
Hey @mobileoverlord, first off -- thanks again for this library. 😃
This is a feature request to add some kind of mechanism to report back whenever connect/disconnect happens.
The use case is that our application connects to another Phoenix application on startup and joins some channels immediately. If there is a disconnection, it's great that
phoenix_clientautomatically retries under the hood. But whenever the connection is reestablished, there's currently no way to be notified. I would like to be notified so that I can immediately re-join the channels.Is that something you'd be open to? I'd be glad to re-work the code in any way if there's a better API and/or write tests. I don't think
report_back_pidis a wonderful name, but it's the best I could think of in the moment. 😄