1
votes

I am using jquery.signalR-2.2.0.js for signalR connection.

I have following code

    var connection = $.hubConnection();
    var proxy = connection.createHubProxy(hubName);

    connection.qs = { 'groupId': groupId };
    proxy.on('connected', function () { });

    connection.logging = true;
    connection.stop();

    connection.transportConnectTimeout = 5000;

    connection.start({ transport: ['webSockets', 'longPolling'] }).done(function () {
        console.log("Connected, transport = " + connection.transport.name);
    })
    .fail(function () { console.log('Could not Connect!'); });

Now issue when I access my website thru chrome using domain name, I get following error:

WebSocket connection to 'ws://xyz/signalr/connect?transport=webSockets&clientProtocol=1.5&groupId=0011600003&connectionToken=nzZP7FOeqXGWVO9gqRZJI3Kl6NBBV%2FSXdgFWR7hvnsNooMr6Qh6vc7YOMzl%2Bb8ExCssRESg4et5mjJ1pQ%2Bb%2BMFPy4nu0aMw9kI7pBzOSTLjzQXLlEVe%2FIqdHj%2Bd7sYpd8nGwA7tMaPBHYxpTt7%2FvbA%3D%3D&connectionData=%5B%7B%22name%22%3A%22spotterenhancementhub%22%7D%5D&tid=3' failed: HTTP Authentication failed; no valid credentials availablestart @ jquery.signalR-2.2.0.min.js:8start @ jquery.signalR-2.2.0.min.js:8d @ jquery.signalR-2.2.0.min.js:8success @ jquery.signalR-2.2.0.min.js:8i @ jquery-2.2.3.min.js:2fireWith @ jquery-2.2.3.min.js:2z @ jquery-2.2.3.min.js:4(anonymous function) @ jquery-2.2.3.min.js:4 jquery.signalR-2.2.0.min.js:8

[14:02:22 GMT-0400 (Eastern Daylight Time)] SignalR: Websocket closed. jquery.signalR-2.2.0.min.js:8

[14:02:22 GMT-0400 (Eastern Daylight Time)] SignalR: Closing the Websocket. jquery.signalR-2.2.0.min.js:8

[14:02:22 GMT-0400 (Eastern Daylight Time)] SignalR: webSockets transport failed to connect. Attempting to fall back. jquery.signalR-2.2.0.min.js:8

[14:02:22 GMT-0400 (Eastern Daylight Time)] SignalR: longPolling transport starting.

Also, this works perfectly with server & domain name thru Firefox. Only issue is in Chrome & domain name.

NOTE: I am using AD - windows authentication

OS : Windows 10

2
If you are using IIS - have you enabled websockets? I believe they are disabled by default. - Pawel
It is already enabled. Actually, when I access website using server name it is working perfectly, however when I use server's proxy name, it is failing. - Avi Kenjale
does the proxy support websockets then and if it is is it configured correctly? - Pawel
This seems to be chrome issue. Funny this is that if you use computer name then it works on windows7 + chrome, but it doesn't work on windows 10 + chrome - Shinya Koizumi

2 Answers

0
votes

I was having weird errors in Chrome, but they only occurred when my site was served over http; your error indicates that's what's happening on your site, because of the unsecured ws:// protocol in the error. Try serving your site over https; that should upgrade your connection to wss://, and potentially solve your issues with Chrome.

0
votes

I ran into a similar problem. Using SignalR 2.2.2 on the client and server, messages suddenly stopped coming through. No errors on either client or server. Just silent failures. Turns out, when my page was loaded over https, SignalR also had to be over a secure connection. When testing locally, I'd use http://localhost for my website, which then had to connect to SignalR over an insecure connection.

So now I have two configuration files, LOCAL.js and PROD.js. Inside of them is a line of code that indicates the appropriate SignalR endpoint to use. An environment variable determines which file is loaded when the web server is started.

Further, I can allow the SignalR client to determine the best connection method. It's working on Chrome, Firefox, Safari, and IE. Good luck!