Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR: "The user identity cannot change during an active SignalR connection" error with windows auth website

I have an MVC 5 website running signalR 2.1.0 using Windows Authentication. Because I'm using windows auth login/logout is handled automatically by IIS. Occassionally I'm getting a 403 error saying "Unrecognized user identity. The user identity cannot change during an active SignalR connection." This doesn't happen all the time, and I can't seem to find a pattern to when it does and does not work. Has anyone else encountered this?

Here is the code on the view:

<script type="text/javascript">
        $(document).ready(function() {
            SignalRSetup();
        });

        function SignalRSetup() {
            // Declare a proxy to reference the hub.
            var hub = $.connection.tokenRequestHub;

            // Create a function that the hub can call to broadcast messages.
            hub.client.updateFromService = function(tokenRequestID, message, success) {
                var msg = "Token Request ID {0} => {1}".format(tokenRequestID, message);
                var notyType = (success) ? 'success' : 'error';
                noty({ text: msg, type: notyType, timeout: 2000 });
                if (success) {
                    refreshGrids();
                }
            };

            $.connection.hub.start();//this is where it errors!
        }
</script>

Any help would be greatly appreciated.

like image 413
jhilden Avatar asked Jul 30 '14 20:07

jhilden


People also ask

What is a SignalR error?

This error may be seen if the project contains a folder called SignalR, which will interfere with the automatically-created proxy. To avoid this error, do not use a folder called SignalR in your application, or turn automatic proxy generation off.

Does SignalR use SSL?

Secure Socket Layers (SSL) protocolIf your SignalR application transmits sensitive information between the client and server, use SSL for the transport. For more information about setting up SSL, see How to set up SSL on IIS 7.

What is SignalR .NET core?

What is SignalR? ASP.NET Core SignalR is an open-source library that simplifies adding real-time web functionality to apps. Real-time web functionality enables server-side code to push content to clients instantly. Good candidates for SignalR: Apps that require high frequency updates from the server.


1 Answers

I think I fixed the issue by adding an [Authorize] attribute to my Hub class. It's only been a few hours, but my SignalR powered page is behaving much better.

like image 171
Andy V Avatar answered Sep 19 '22 22:09

Andy V