Click here to Skip to main content
15,907,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello all,

I am using autobahn websocket[^] to create communication between my server and android client. When I hosted my web socket on my site IIS and connect from my android, it is working fine.
Site URL to connect: "ws://mysite.com/WSockets/WSHttpHandler.ashx?name=android".

But when I connect it to same server through Local Area Network with IP Address, I got problem. Connection was opened. Then it closed with the error "Websocket protocol violation".
LAN URL to connect: "ws://192.168.1.22/[MyApplicationName_ON_IIS]/WSockets/WSHttpHandler.ashx?name=android". URL should be correct because connection can be openned. But why it was closed?

This is what I found on autobahn website about this error -
Autobahn will NOT validate the bytes of a text payload being sent for actually being valid UTF8. You MUST ensure that you only provide valid UTF8 when sending text messages. If you produce invalid UTF8, a conforming WebSocket peer will close the WebSocket connection due to the protocol violation.

But I don't know what to do my payload with UTF8.

In my websocket handler, when client connected, I just Broadcast the message like below.
C#
public override void OnOpen()
        {
            try
            {
                this.name = this.WebSocketContext.QueryString["name"];
                clients.Add(this);
                clients.Broadcast(name + " has connected.");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

And it is working perfectly when I connect through WAN.

Please advise.

Thanks in advanced
tslin
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900