Conversation
dsrees
requested changes
Feb 20, 2019
Owner
dsrees
left a comment
There was a problem hiding this comment.
Good find, thanks for the fix. Small change in the tests and then we can merge this
|
|
||
| socket.onOpen(mockSocket, null) | ||
|
|
||
| assertTrue(socket.isConnected) |
Owner
There was a problem hiding this comment.
This project uses Google's Truth lib for assertions
assertThat(socket.isConnect).isTrue()
Contributor
Author
There was a problem hiding this comment.
Missed that. Updated now.
Currently `isConnected` is true when `connection` exists. However, this is different from JS and Swift implementations. In [JS][1] and [Swift][2] implementations `isConnected` is true only when the socket is actually connected. One of the problems this causes was the channels were closed during the following scenario: 1. WebSocket connection established, one channel is joined.. 2. Internet/Wifi disabled -> connection fails. 3. We periodically call `phxSocket.connect()` to reconnect. 4. Channels [try to rejoin as `isConnected` is true][4], but `phx_join` messages are being queued instead as connection is still not established. 5. Internet/Wifi enabled -> multiple queued `phx_join` messages are sent, Phoniex Server relies `phx_close` to all join messages but last. On `phx_close` the channel is removed from the socket, even tho the logs show that the state is being received. `connect` method is changed to use `connection != null` check, the same way it's done in [JS version][3]. [1]: https://github.com/phoenixframework/phoenix/blob/93db5ff3adf4c91a1ff1996e819e7dd5dfbddf1a/assets/js/phoenix.js#L906 [2]: https://github.com/davidstump/SwiftPhoenixClient/blob/ade5c27051a96aeeedff1594cb3e176b57a02f96/Sources/Socket.swift#L180 [3]: https://github.com/phoenixframework/phoenix/blob/93db5ff3adf4c91a1ff1996e819e7dd5dfbddf1a/assets/js/phoenix.js#L782 [4]: https://github.com/dsrees/JavaPhoenixClient/blob/master/src/main/kotlin/org/phoenixframework/PhxChannel.kt#L74
6d1ee99 to
06a20eb
Compare
Contributor
Author
|
One question. In the case of calling |
Contributor
Author
|
I checked ☝️myself, and |
Contributor
Author
|
Hey, would you be able to publish a new version with this fix any time soon? |
Owner
|
@ostap0207 |
Contributor
Author
|
Thanks a lot! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently
isConnectedis true whenconnectionexists. However, thisis different from JS and Swift implementations.
In JS and Swift implementations
isConnectedis true only when thesocket is actually connected.
One of the problems this causes was that channels were closed during the
following scenario:
phxSocket.connect()to reconnect.isConnectedis true, butphx_joinmessages are being queued instead as connection is still not established.
phx_joinmessages are sent,Phoniex Server relies
phx_closeto all join messages but last.On
phx_closethe channel is removed from the socket, even tho the logsshow that the state is being received.
connectmethod is changed to useconnection != nullcheck, the sameway it's done in JS version.