Reputation: 1952
I have written a simple websocket server/ client. The server is written using C# (System.Net.WebSockes) and client is javascript (although server technology is irrelevant because I have tested it with signalr and got the same error during the handshake of websocket transport). The problem is that:
1- on some clients I can easily connect to server and works very well.
2- on some other clients I get an error code 1006 during handshake and in these clients when I turn on a proxy app such as PSiphon it can connect to the server. However, it gets disconnected after about 6 seconds.
I'm really super confused, and finally after hours of trying I have decided to put a question here. I don't think that it`s related to code, but I put it here anyway.
var url = 'ws://' + location.host + '/socket';
var socket = new WebSocket(url);
Update 1: i have contacted system administrator (Hosting Company) and they said it might be because of the ISP of clients. if that`s the case i would appreciate any tip to make sure if there is some kind of proxy server that causes the trouble?
Update 2: as @vtortola mentioned i created a self signed certificate and added to website (IIS and Plesk). there was some improvement but still getting disconnections
Thanks in advance..
Upvotes: 0
Views: 312
Reputation: 35925
It smells like proxy issues to me. Use secure connections (wss://
) and check if it gets better. Basically, if some of your clients are behind proxies, the WebSocket connections can misbehave in many unexpected ways.
How HTML5 Web Sockets Interact With Proxy Servers.
Upvotes: 1