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

Comments

Projects
None yet
7 participants
@edevil

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

This comment has been minimized.

Show comment
Hide comment
@igoodrich

igoodrich Jun 30, 2016

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.

Contributor

igoodrich commented Jun 30, 2016

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

This comment has been minimized.

Show comment
Hide comment
@Voronchuk

Voronchuk Jul 13, 2016

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 }

Voronchuk commented Jul 13, 2016

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

This comment has been minimized.

Show comment
Hide comment
@igoodrich

igoodrich Jul 13, 2016

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.

Contributor

igoodrich commented Jul 13, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@Voronchuk

Voronchuk Jul 14, 2016

@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.

Voronchuk commented Jul 14, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@alexspurling

alexspurling Aug 11, 2016

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

alexspurling commented Aug 11, 2016

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

@CD1212

This comment has been minimized.

Show comment
Hide comment
@CD1212

CD1212 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.

CD1212 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

This comment has been minimized.

Show comment
Hide comment
@djthread

djthread Mar 15, 2017

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!

djthread commented Mar 15, 2017

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 maxstr added the enhancement label Mar 20, 2017

@maxstr

This comment has been minimized.

Show comment
Hide comment
@maxstr

maxstr Mar 21, 2017

Collaborator

@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!

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