我有一个在连接打开后看起来像这样的片段
receiveEvents :: WS.Connection -> Document -> IO()
receiveEvents conn document = forever $ do
putStrLn "receive events"
evnt <- WS.receiveData conn
let val = fromJust $ decode' evnt
liftIO $ atomically $ do
writeTChan (eventQueue document) val
如果从客户端发送事件,则此代码可以正常工作,但在关闭一些不活动连接后,我在客户端(web javascript)上出现错误连接已关闭(关闭了websockets)。一些不活动后,websockets是否关闭。此外,如果这是在主线程中它工作正常吗?