Skip to content

Commit 4d16007

Browse files
authored
chore: kickoff release
2 parents 2a233c4 + ad53816 commit 4d16007

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

AmplifyPlugins/API/Sources/AWSAPIPlugin/AppSyncRealTimeClient/AppSyncRealTimeClient.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)