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 {
298298 . eraseToAnyPublisher ( )
299299 }
300300
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+
301311 private static func decodeAppSyncRealTimeResponseError( _ data: JSONValue ? ) -> [ Error ] {
302312 let knownAppSyncRealTimeRequestErorrs =
303313 Self . decodeAppSyncRealTimeRequestError ( data)
@@ -414,7 +424,7 @@ extension AppSyncRealTimeClient {
414424 . sink ( receiveValue: {
415425 self . log. debug ( " [AppSyncRealTimeClient] KeepAlive timed out, disconnecting " )
416426 Task { [ weak self] in
417- await self ? . disconnect ( )
427+ await self ? . reconnect ( )
418428 } . toAnyCancellable. store ( in: & self . cancellables)
419429 } )
420430 . store ( in: & cancellablesBindToConnection)
You can’t perform that action at this time.
0 commit comments