PING error now throws error to restart SMPClient for more reliable re-connection (#342)

This commit is contained in:
Evgeny Poberezkin authored and GitHub committed 2022-03-29 13:21:21 +04:00
1 parent cd22e06b3a
commit 62acbc4ad4
2 files changed
+3 -3

No files matched your search

+2 -2
View File
@@ -114,7 +114,7 @@ smpDefaultConfig =
defaultTransport = ("5223", transport @TLS),
tcpTimeout = 4_000_000,
tcpKeepAlive = Just defaultKeepAliveOpts,
smpPing = 600_000_000 -- 10min
smpPing = 300_000_000 -- 5 min
}
data Request = Request
@@ -194,7 +194,7 @@ getSMPClient smpServer cfg@SMPClientConfig {qSize, tcpTimeout, tcpKeepAlive, smp
ping :: SMPClient -> IO ()
ping c = forever $ do
threadDelay smpPing
runExceptT $ sendSMPCommand c Nothing "" PING
void . either throwIO pure =<< runExceptT (sendSMPCommand c Nothing "" PING)
process :: SMPClient -> IO ()
process SMPClient {rcvQ, sentCommands} = forever $ do
+1 -1
View File
@@ -52,7 +52,7 @@ foreign import capi "netinet/tcp.h value TCP_KEEPINTVL" _TCP_KEEPINTVL :: CInt
foreign import capi "netinet/tcp.h value TCP_KEEPCNT" _TCP_KEEPCNT :: CInt
#endif
#endif
setSocketKeepAlive :: Socket -> KeepAliveOpts -> IO ()
setSocketKeepAlive sock KeepAliveOpts {keepCnt, keepIdle, keepIntvl} = do