From 4f4b4f7eeec151f7535bcdae6c269d4f6f65900c Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:03:43 +0000 Subject: [PATCH] only reconnect client on temporary errors in single subscription too (not currently used) (#616) * only reconnect client on temporary errors in single subscription too (not currently used) * refactor --- src/Simplex/Messaging/Agent/Client.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Messaging/Agent/Client.hs b/src/Simplex/Messaging/Agent/Client.hs index e4ddda84f..205d13957 100644 --- a/src/Simplex/Messaging/Agent/Client.hs +++ b/src/Simplex/Messaging/Agent/Client.hs @@ -611,9 +611,11 @@ subscribeQueue c rq@RcvQueue {connId, server, rcvPrivateKey, rcvId} = do modifyTVar' (subscrConns c) $ S.insert connId RQ.addQueue rq $ pendingSubs c r <- withLogClient c server rcvId "SUB" $ \smp -> - liftIO (runExceptT (subscribeSMPQueue smp rcvPrivateKey rcvId) >>= processSubResult c rq) + liftIO $ runExceptT (subscribeSMPQueue smp rcvPrivateKey rcvId) >>= processSubResult c rq case r of - Left e -> reconnectServer c server >> throwError (protocolClientError SMP (B.unpack $ strEncode server) e) + Left e -> do + when (temporaryClientError e) $ reconnectServer c server + throwError (protocolClientError SMP (B.unpack $ strEncode server) e) _ -> pure () processSubResult :: AgentClient -> RcvQueue -> Either ProtocolClientError () -> IO (Either ProtocolClientError ())