Open MayankMintoak opened 1 month ago
Hello @MayankMintoak, thank you for reporting the issue. I have a few questions:
Could you provide the crash report? That would make it easier for us to reproduce.
Are you suspending and resuming connection when putting the app in background? You can do it in SceneDelegate
so that the app does not heep the connection alive when in background:
func sceneDidBecomeActive(_ scene: UIScene) {
Task {
try await natsClient?.resume()
print("resumed")
}
}
func sceneWillResignActive(_ scene: UIScene) {
Task {
try await natsClient?.suspend()
print("suspended")
}
}
What do you mean by "unspecified period of time"? Are there e.g. nats server restarts during this period or any reconnection attempts?
Observed behavior
Description: The app crashes in the ConnectionHandler.connect() method of nats.swift when the app is either idle for an extended random period or has been moved to the background. Upon resuming or interacting with the app after this idle period, the app crashes, and the crash report points to the connect() method in nats.swift.
Crash Details:
File: nats.swift Method: ConnectionHandler.connect() Line: Occurs during reconnection attempt (as seen in the attached screenshot).
Observed Behavior:
The app crashes and navigates to the ConnectionHandler.connect() method in the nats.swift file.
Expected behavior
The connection handler should gracefully handle reconnections or retries without crashing, even after idle or background sessions.
Server and client version
0.3.0
Host environment
No response
Steps to reproduce
Steps to Reproduce:
Open the app. Let the app remain idle for an unspecified period of time (can vary randomly). Alternatively, put the app in the background after it is connected. After the idle period or when resuming the app from the background, try interacting with the app. The app crashes, and the crash report indicates the ConnectionHandler.connect() method in nats.swift.