File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
AmplifyPlugins/API/Sources/AWSAPIPlugin/AppSyncRealTimeClient Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -298,6 +298,16 @@ actor AppSyncRealTimeClient: AppSyncRealTimeClientProtocol {
298
298
. eraseToAnyPublisher ( )
299
299
}
300
300
301
+ private func reconnect( ) async {
302
+ do {
303
+ log. debug ( " [AppSyncRealTimeClient] Reconnecting " )
304
+ await disconnect ( )
305
+ try await connect ( )
306
+ } catch {
307
+ log. debug ( " [AppSyncRealTimeClient] Failed to reconnect, error: \( error) " )
308
+ }
309
+ }
310
+
301
311
private static func decodeAppSyncRealTimeResponseError( _ data: JSONValue ? ) -> [ Error ] {
302
312
let knownAppSyncRealTimeRequestErorrs =
303
313
Self . decodeAppSyncRealTimeRequestError ( data)
@@ -414,7 +424,7 @@ extension AppSyncRealTimeClient {
414
424
. sink ( receiveValue: {
415
425
self . log. debug ( " [AppSyncRealTimeClient] KeepAlive timed out, disconnecting " )
416
426
Task { [ weak self] in
417
- await self ? . disconnect ( )
427
+ await self ? . reconnect ( )
418
428
} . toAnyCancellable. store ( in: & self . cancellables)
419
429
} )
420
430
. store ( in: & cancellablesBindToConnection)
You can’t perform that action at this time.
0 commit comments