locked
SignalR authentication with .NET client works locally but not on server RRS feed

  • Question

  • User327441648 posted

    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:
    {
    Server: Microsoft-IIS/8.5
    WWW-Authenticate: Negotiate
    WWW-Authenticate: NTLM
    X-Powered-By: ASP.NET
    Date: Thu, 20 Apr 2017 19:40:41 GMT
    Content-Length: 1293
    Content-Type: text/html
    }

    I see the above error in the browser developer tool and it happens when this line is run:

    hubConnection.Start().Wait();

    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?

    Friday, April 21, 2017 7:11 PM

All replies

  • User-271186128 posted

    Hi zhaoli86,

    zhaoli86

    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

    Best regards,
    Dillion

    Monday, April 24, 2017 7:07 AM
  • User327441648 posted

    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? 

    Wednesday, April 26, 2017 2:28 PM
  • User-271186128 posted

    hi zhaoli86

    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.

    Best regards,
    Dillion

    Friday, May 5, 2017 6:33 AM