jaspervdj / websockets

A Haskell library for creating WebSocket-capable servers
http://jaspervdj.be/websockets
BSD 3-Clause "New" or "Revised" License
405 stars 112 forks source link

Unexpected ConnectionClosed #212

Open bapcyk opened 3 years ago

bapcyk commented 3 years ago

This code always raises ConnectionClosed exception (in the loop). It never receives any data from the server. The Web socket server (aria2c) supports ver. 13 RFC6455 and the receiving of the data in Python works fine. So it seems that the problem is in the Haskell library websockets, not in the server itself. Maybe more special way of the receiving is needed, I don't know.

...

recv :: SomeState -> WSC.Connection -> IO ()
recv st conn = forever $ body `catch` onError
    where
        onError (x::SomeException) = do
            ...
            threadDelay 1000000

        body = do
            msg <- WSC.receiveDataMessage conn
            print msg
            threadDelay 1000

runMe :: SomeState -> IO ()
runMe st = do
    SC.withSocketsDo $ WSC.runClient "localhost" 6800 "/jsonrpc" p
    where p conn = void $ forkIO $ recv st conn
domenkozar commented 6 months ago

Would be great to have a way to reproduce the issue.