on master help sign in
Remove `forkPingThread` callback from field `pendingOnAccept` of record `PendingConnect

Which prevents Snap from killing the connection by constantly sending pings. Issue addressed here: https://github.com/jaspervdj/websockets-snap/issues/5

commite333ce75c5429a5527521342f172783448950baf authorbanacorn <banacorn@gmail.com> dateTue 19 Nov 2013, 00:10 (13 years ago) parent248fe35
1 file changed+1−15
wai-websockets/Network/Wai/Handler/WebSockets.hs+1−15
wai-websockets/Network/Wai/Handler/WebSockets.hs+1−15
@@ -57,27 +57,13 @@ runWebSockets opts req app _ conn = do
5757 let pc = WS.PendingConnection
5858 { WS.pendingOptions = opts
5959 , WS.pendingRequest = req
60− , WS.pendingOnAccept = forkPingThread
60+ , WS.pendingOnAccept = \_ -> return ()
6161 , WS.pendingIn = is
6262 , WS.pendingOut = os
6363 }
6464
6565 liftIO $ app pc
6666
67−--------------------------------------------------------------------------------
68−-- | Start a ping thread in the background
69−forkPingThread :: WS.Connection -> IO ()
70−forkPingThread conn = do
71− _ <- forkIO pingThread
72− return ()
73− where
74− pingThread = handle ignore $ forever $ do
75− WS.sendPing conn (BC.pack "ping")
76− threadDelay $ 30 * 1000 * 1000
77−
78− ignore :: SomeException -> IO ()
79− ignore _ = return ()
80−
8167------------------------------------------------------------------------------
8268-- | Converts a 'Connection' to an 'InputStream' \/ 'OutputStream' pair. Note that,
8369-- as is usually the case in @io-streams@, writing a 'Nothing' to the generated