Can not connect to websocket server using WebSocket4Net

3.2k Views Asked by At

I have a mochiweb as WebSocket server; connectivity using JavaScript from Chrome browser as ws client went smooth (open, send message, close). However, when I tried to connect from C# using websocket4Net, I always get below error from mochiweb.

=CRASH REPORT==== 30-Jan-2013::16:57:41 === crasher: initial call: mochiweb_acceptor:init/3 pid: <0.228.0> registered_name: [] exception error: no case clause matching {error,timeout} in function mochiweb_http:websocket_init_with_origin_validated/4 (mochiweb_http.erl, line 292) in call from mochiweb_http:headers_ws_upgrade/4 (mochiweb_http.erl, line 192) ancestors: [cim_https,<0.166.0>] messages: [] links: [<0.167.0>] dictionary: [] trap_exit: false status: running heap_size: 1597 stack_size: 24 reductions: 1585

my C# snippet:

        webSocketClient = new WebSocket("wss://localhost:8080/login");
                    webSocketClient.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(webSocketClient_Error) ;
        webSocketClient.AllowUnstrustedCertificate = true;
        webSocketClient.Opened += new EventHandler(webSocketClient_Opened);
        webSocketClient.Closed += new EventHandler(webSocketClient_Closed);
        webSocketClient.MessageReceived += new EventHandler<MessageReceivedEventArgs>(webSocketClient_MessageReceived);
        webSocketClient.Open();

Is there any parameter that I've missed ? Any idea on how to trace this ?

1

There are 1 best solutions below

0
On

Found the issue. Apparently, Mochiweb only supports what in websocket4net is known as Hybi00 -no support for RFC 6455 yet. Seems like now I have to patch my mochiweb.