Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR 2 fails on Azure

I deployed an ASP.NET 5 MVC 6 app on Azure, and ran into this problem with SignalR 2: when starting connection from client, call to

/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B"name"%3A"gameHub"%7D%5D&_=1460028930688

fails with error 500.

The exception behind error 500 is this:

Exception Details: System.Security.Cryptography.CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.]

I read and tried solution suggested at SignalR CryptographicException on AzureWebsites, but id didn't work for me.

As I understand, Azure doesn't allow LoadUserProfile.

Any workaround?

like image 999
AunAun Avatar asked Apr 07 '16 11:04

AunAun


People also ask

How many SignalR connections can a server handle?

In the default mode, the app server creates five server connections with Azure SignalR Service. The app server uses the Azure SignalR Service SDK by default. In the following performance test results, server connections are increased to 15 (or more for broadcasting and sending a message to a big group).

Why does SignalR disconnect?

If a server does not become available within the disconnect timeout period, the SignalR connection ends. In this scenario, the Closed event ( disconnected in JavaScript clients) is raised on the client but OnDisconnected is never called on the server.

Is SignalR two way communication?

SignalR is a two-way RPC protocol (request–response protocol) used to exchange messages between client and server (bi-directional communication) that works independently of transport protocols.


1 Answers

I had the same problem and my fix was to add a call to UseAesDataProtectorProvider() before my call to MapSignalR(). Hope this helps someone.

like image 140
Cokes Avatar answered Oct 08 '22 23:10

Cokes