Skip to content

Unexpected ConnectionClosed #212

@bapcyk

Description

@bapcyk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions