Browse Source

BrokerServer: add keepalive settings

master
Denis Tereshkin 4 years ago
parent
commit
f6295cd0d6
  1. 6
      src/ATrade/Broker/Server.hs

6
src/ATrade/Broker/Server.hs

@ -77,6 +77,11 @@ startBrokerServer brokers c ep notificationsEp tradeSinks params = do
zapApplyCertificate cert notificationsSock zapApplyCertificate cert notificationsSock
Nothing -> return () Nothing -> return ()
bind sock (T.unpack ep) bind sock (T.unpack ep)
setTcpKeepAlive On notificationsSock
setTcpKeepAliveCount (restrict 5) notificationsSock
setTcpKeepAliveIdle (restrict 60) notificationsSock
setTcpKeepAliveInterval (restrict 10) notificationsSock
bind notificationsSock (T.unpack notificationsEp) bind notificationsSock (T.unpack notificationsEp)
tid <- myThreadId tid <- myThreadId
compMv <- newEmptyMVar compMv <- newEmptyMVar
@ -121,6 +126,7 @@ notificationCallback state n = do
where where
addNotification clientIdentity n = do addNotification clientIdentity n = do
debugM "Broker.Server" $ "Sending notification to client [" <> T.unpack clientIdentity <> "]"
atomicMapIORef state (\s -> atomicMapIORef state (\s ->
case M.lookup clientIdentity . pendingNotifications $ s of case M.lookup clientIdentity . pendingNotifications $ s of
Just ns -> s { pendingNotifications = M.insert clientIdentity (n : ns) (pendingNotifications s)} Just ns -> s { pendingNotifications = M.insert clientIdentity (n : ns) (pendingNotifications s)}

Loading…
Cancel
Save