Skip to content

LiveQuery: automatically try to reconnect after errors -1001 and -1011 #217

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

Merged
merged 3 commits into from
Aug 27, 2021
Merged

Conversation

lsmilek1
Copy link
Contributor

@lsmilek1 lsmilek1 commented Aug 25, 2021

At certain scenarios when:

  • the internet connection is being held at 100% loss the LQ websocket receives urlError.errorCode -1001 "The request timed out."
  • sometimes when the Parse Server is being restarted, the LQ websocket receives urlError.errorCode -1011 "There was a bad response from the server."

This eventually falls through the error check on the line 539 not attempting again.

func isURLError(_ error: Error) -> Bool {
guard let urlError = error as? URLError else {
notificationQueue.async {
self.receiveDelegate?.received(error)
}
return false
}
if urlError.errorCode == -1005 {
isSocketEstablished = false
open(isUserWantsToConnect: false) { error in
guard let error = error else {
// Resumed task successfully
return
}
self.notificationQueue.async {
self.receiveDelegate?.received(error)
}
}
} else {
notificationQueue.async {
self.receiveDelegate?.received(error)
}
}
return true
}

-1001 "The request timed out."
-1011 "There was a bad response from the server."
@codecov
Copy link

codecov bot commented Aug 25, 2021

Codecov Report

Merging #217 (fac39cc) into main (16cbcfa) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head fac39cc differs from pull request most recent head 54ac0b2. Consider uploading reports for the commit 54ac0b2 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
- Coverage   83.59%   83.57%   -0.02%     
==========================================
  Files          76       76              
  Lines        7259     7259              
==========================================
- Hits         6068     6067       -1     
- Misses       1191     1192       +1     
Impacted Files Coverage Δ
Sources/ParseSwift/LiveQuery/ParseLiveQuery.swift 74.38% <100.00%> (ø)
Sources/ParseSwift/Objects/ParseUser.swift 82.89% <0.00%> (-0.15%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16cbcfa...54ac0b2. Read the comment docs.

@cbaker6
Copy link
Contributor

cbaker6 commented Aug 25, 2021

Can you add an entry in the change log file: https://github.com/parse-community/Parse-Swift/blob/main/CHANGELOG.md

Can you also add something more descriptive in the description of this PR: #217 (comment)

@cbaker6 cbaker6 linked an issue Aug 25, 2021 that may be closed by this pull request
3 tasks
@cbaker6 cbaker6 changed the title Adding following codes to check for LiveQuery reconnection: LiveQuery: automatically try to reconnect after errors -1001 and -1011 Aug 26, 2021
@cbaker6
Copy link
Contributor

cbaker6 commented Aug 26, 2021

@lsmilek1 thanks for your contribution! After updating the change log, we will merge your PR.

@cbaker6 cbaker6 merged commit 305792b into parse-community:main Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

urlError.errorCode -1011 and -1001 for LQ reconnection
2 participants