From f8cf0e717959c0b3d388db1a5517d30ff384b1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20G=C3=89RARD?= Date: Sun, 27 May 2018 18:25:21 +0200 Subject: [PATCH] Send websocket ping every 30 seconds --- src/Tunnel.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Tunnel.hs b/src/Tunnel.hs index 3e71f616..9f344ec5 100644 --- a/src/Tunnel.hs +++ b/src/Tunnel.hs @@ -58,7 +58,7 @@ tunnelingClientP cfg@TunnelSettings{..} app conn = onError $ do debug "Oppening Websocket stream" stream <- connectionToStream conn - ret <- WS.runClientWithStream stream serverHost (toPath cfg) WS.defaultConnectionOptions [] (app . toConnection) + ret <- WS.runClientWithStream stream serverHost (toPath cfg) WS.defaultConnectionOptions [] run debug "Closing Websocket stream" return ret @@ -66,6 +66,9 @@ tunnelingClientP cfg@TunnelSettings{..} app conn = onError $ do where connectionToStream Connection{..} = WS.makeStream read (write . toStrict . fromJust) onError = flip catch (\(e :: SomeException) -> return . throwError . WebsocketError $ show e) + run cnx = do + WS.forkPingThread cnx 30 + app (toConnection cnx) tlsClientP :: MonadError Error m => TunnelSettings -> (Connection -> IO (m ())) -> (Connection -> IO (m ()))