Skip to content
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

Re-join channels on reconnect #9

Open
edevil opened this issue Jun 27, 2016 · 8 comments
Open

Re-join channels on reconnect #9

edevil opened this issue Jun 27, 2016 · 8 comments

Comments

@edevil
Copy link

edevil commented Jun 27, 2016

As it stands, when there is a problem with the websocket it is automatically reconnected. However, the previously joined channels are not rejoined, and we don't seem to get any message that would allow the client to perform that task (although I think that the library should take care of this).

@igoodrich
Copy link
Contributor

I just filed a related issue with elm-lang/websocket:
elm-lang/websocket#10

I think re-joining the channels on re-connect would be impossible given the current WebSocket.elm API. It's missing notification of re-connect. For the reasons outlined in the issue above, I think it's a general problem with the WebSocket module and not specific to phoenix at all.

Anyway, we'll see if anyone is willing to address. If not, I think the option is to copy WebSocket.elm and modify it notify of reconnects and republish as a separate package.

Also, I agree that this library should re-join channels on re-connect. At the very least, it needs to notify the clients of this library that a re-connect has happened so that they can tell the server who they are and catch up.

@Voronchuk
Copy link

I'm wondering can't the library re-join the channel, having unmatched topic in response reason?

Phoenix message: { event = "phx_reply", topic = "rooms:lobby", payload = { status = "error", response = { reason = "unmatched topic" } }, ref = Just 2119 }

@igoodrich
Copy link
Contributor

@Voronchuk I think the underlying elm websocket library auto re-connects in such a way that the elm-phoenix-socket library will never get that message and so can't respond to it.

@Voronchuk
Copy link

@igoodrich so { socket | debug = True } this part simply delegates the debugging to elm websocket which actually renders those debug messages and we can't intercept those messages on elm-phoenix-socket level... makes sense.

@alexspurling
Copy link

Could I ask, why does the websocket library issue a re-connect after 60s of inactivity?

@dyerc
Copy link

dyerc commented Oct 28, 2016

Has anyone found a work around for this?

Phoenix.Channel.onClose or Phoenix.Channel.onError don't appear to be called after a websocket disconnects, so there doesn't appear to be a way to reconnect there. I am hitting the same unmatched topic error as others have mentioned.

@djthread
Copy link

I am also very keen to solve this problem ... and the exponential backoff feature, too, seems pretty essential for a production app. Any developments on any of this out there?

Big-time kudos to @fbonetti and everyone contributing to this great library tying together a pair my very favorite tools!

@maxstr
Copy link
Collaborator

maxstr commented Mar 21, 2017

@djthread, as noted above fixing this in a native Elm library isn't possible until the Elm WebSocket library is improved. It's unfortunately pretty bare bones right now. You may be interested in this effect manager though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants