Skip to content

Amplify.API.subscribe fail after background back #3914

@smediomike

Description

@smediomike

Describe the bug

Application can not create subscribe once application go to background and then foreground. this issue did not happen on 2.17.1 and 2.26.1 SDK

Steps To Reproduce

1, start application 
2, create Amplify.API.subscribe(request: .subscription(of: BroadcastMessage.self, type: .onUpdate))
3, when all initialized, go to background
4, wait for one 20 seconds
5, go to foreground
6, Subscription has terminated will happen 
   do {
                for try await subscriptionEvent in messagesubscription {
   } catch {
                print("Subscription has terminated with \(error)")
   } 

7, after checked network status and subscribe status and restart this subscribe again
8, fail and can not create this subscribe again

Expected behavior

same to 2.26.1, application go to foreground, still can use subscribe or can create subscribe.

Amplify Framework Version

2.43.0

Amplify Categories

API, DataStore

Dependency manager

Swift PM

Swift version

5.0

CLI version

12.1.1

Xcode version

xcode16

Relevant log output

DataStoreIncomingAsyncSubscriptionEventPublisher] [InitializeSubscription.1] API.subscribe failed for `Document` error: WebSocketClient connection aborted\
Subscription has terminated with APIError: WebSocketClient connection aborted\
Recovery suggestion: WebSocketClient connection aborted\
Caused by:\
Error Domain=NSURLErrorDomain Code=-1005 "(null)"\

Is this a regression?

Yes

Regression additional context

2.17.1 and 2.26.1 are okay. our QA did such test, but 2.43.0 are always failed. 100% reproduce rate.

Platforms

iOS

OS Version

16.7/17.1/18.0

Device

iPhoneX/iPhone12/iPadPro

Specific to simulators

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiIssues related to the API categorybugSomething isn't workingclosing soonThis issue will be closed in 7 days unless further comments are made.pending-community-responseIssue is pending response from the issue requestor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions