Last post May 05, 2017 06:33 AM by Zhi Lv - MSFT
Apr 21, 2017 07:11 PM|zhaoli86|LINK
I'm hosting my signalR in IIS, and I have a .net client that resides in the same website. I'm using windows authentication so credentials are set this way:
hubConnection.Credentials = CredentialCache.DefaultCredentials;
This all work when I run the site locally, but it would give me a 401 error when deployed on a server:
SignalR: myhub.DoStuff failed to execute. Error: StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
Date: Thu, 20 Apr 2017 19:40:41 GMT
I see the above error in the browser developer tool and it happens when this line is run:
I'm pretty sure the credential itself is right, because when I run the site locally, and put in the hub url that's deployed on the server, and pass in a credential for that server, I am able to start the hubConnection.
So what could be something that's preventing the SignalR .Net client from authenticating on a server, but not locally?
Apr 24, 2017 07:07 AM|Zhi Lv - MSFT|LINK
SignalR authentication with .NET client works locally but not on server
It seems you have not enable the Windows Authentication in IIS on your Server. Please follow the steps in below:
1. Login to your server machine, and open the IIS manager
2. Select current site in Sties Tree in the left
3. Double click the “Authentication” (configure the authentication settings for sites and applications)
4. Change the “Windows Authentication” status to Enable
Apr 26, 2017 02:28 PM|zhaoli86|LINK
Thanks for your reply.
I do have Windows Authentication enabled on the server.
Now I am leaning towards the theory that the credential passed to the .NET client of SignalR doesn't have enough rights. Basically every time I get the 401 error, I can see a new Audit Failure entry popping up in the server's event viewer log, saying the
credential that was used couldn't log on.
Does anyone know what rights need to be granted to the account?
May 05, 2017 06:33 AM|Zhi Lv - MSFT|LINK
You could set Credentials like this:
connection.Credentials = new NetworkCredential("username", "password");
If you have any other questions, please feel free to contact me any time.