Resolve race condition by ensuring that op=connected has been received before sending a new subscribe event#48
Conversation
Codecov Report
@@ Coverage Diff @@
## master #48 +/- ##
============================================
+ Coverage 67.13% 68.11% +0.98%
- Complexity 78 82 +4
============================================
Files 11 11
Lines 359 367 +8
Branches 24 24
============================================
+ Hits 241 250 +9
+ Misses 104 103 -1
Partials 14 14
Continue to review full report at Codecov.
|
| subscriptions.append(requestId, subscription); | ||
|
|
||
| if (inAnyState(WebSocketClient.State.CONNECTED)) { | ||
| // TODO: differentiate between state=CONNECTED, vs received op=connected response |
There was a problem hiding this comment.
whoops, this should have been removed
before sending a new subscribe event. Fixes parse-community#46
|
@rogerhu @mmimeault ping? We'd like to get this merged to at least get a SNAPSHOT built in order to fix the bug in our app. |
|
Nice find and thanks for the test. |
|
Can we please get a new release or snapshot built to include these changes? We're working towards a push of a release on our Android platform very soon. |
|
We have auto snapshots via Sonatype here: https://oss.sonatype.org/content/repositories/snapshots/com/parse/parse-livequery-android/1.0.3-SNAPSHOT/ I can push a release though. |
|
release works if thats easy enough. thanks. |
|
@rogerhu was the release published? we're not seeing it available on sonatype yet. |
|
It's on jCenter (point your Gradle config to jcenter() instead of mavenCentral()) already. Getting Bintray to approve auto-syncing to Sonatype. |
ParseLiveQueryClient.subscribe()checks if the socket state is "CONNECTED" before sending the subscribe event. If it's not, it triggers a reconnect.The problem is that when the socket connects, we also send the
op=connectevent to the server, and wait for the server to respond withop=connected. At the time ofop=connected, we then send any pending subscribe messages.If a subscribe request comes in after the socket is connected, but before the
op=connectedmessage comes from the server, we will end up with that subscription duplicated, and we'll receive duplicated events as a result.