Comments (5)
Well, I can reproduce this. It also happens with Mobile Safari and a plain web client against my test SignalR server. Is it feasible to reconnect when the app enters the foreground?
from swiftr.
If I add manual reconnect on disconnected, it will reconnect after the app enters the foreground. Looks like this is a workaround.
The built in auto reconnect on disconnected seems not to kick in for this scenario.
from swiftr.
Commit 1bd2784 to SwiftR.js removed the 5 second auto-reconnect. I did this so you could stop/start the connection yourself without it reconnecting automatically after you stop. This would mean you need to reconnect manually on the disconnected
event. I could make an autoReconnect
property that lets you opt in/out of this behavior.
I don't know if there's some best practice for doing this with SignalR. FWIW, in my own use, I've never needed to stop/start the connection, and always relied on a 5 second auto-reconnect.
from swiftr.
Thanks, the manual reconnect works well so far.
from swiftr.
FYI, for anyone else that reads this: As of commit 8e3a34d, you could also use an error handler like this to reconnect on timeout:
connection.error = { error in
print("Error: \(error)")
if let source = error?["source"] as? String where source == "TimeoutException" {
print("Connection timed out. Restarting...")
connection.start()
}
}
from swiftr.
Related Issues (20)
- "There was an error invoking Hub" Swift 4 HOT 5
- My signalR connection is established but can not invoke the hub function.
- hub.invoke(...) Won't handle any response.
- SignalR 1.0.0-preview2-final in .NET core?
- SwiftR 0.14.0 is not connecting with server using Xcode 9.3, Swift 4.1 and iOS 11.3 HOT 3
- dyld: Library not loaded: @rpath/SwiftR.framework/SwiftR
- Spelling issue
- Hub.on is not getting called after establishing connection HOT 1
- How to remove registed hub in hubs
- How can i upgrade from v2.2 to v2.4?
- Close a persistent connection
- loging connection information
- How to remove event from chathub?
- Xcode 10 can't run in swift 4 HOT 5
- Mac Catalyst support! HOT 3
- UIWebView deprecated from iOS 13 HOT 1
- UIWebView deprecated HOT 9
- not supporting latest iOS . please make it compatible for swift 5 and iOS 15.
- Solved UIWebView deprecated and Swift 5 compatibility
- Remove the listener of .on method
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftr.