Question

We're attempting to migrate from SignalR 1.x to SignalR 2.x and have run into some issues.

The app has been using SignalR 1.x to do "real time" (push) communcations between the backend and frontend clients. In SignalR 1.x, we had access to the System.Web HttpContext sessions state. Specifically, we were using the SessionId to keep track of and manage active SignalR connections.

We're now attempting to upgrade to SignalR 2.x. Unfortunately, access the the System.Web HttpContext is no longer supported. This is because SignalR requests are handled before the session state module is initialized.

Now we're tasked with coming up with some other way to uniquely track connections other than the SessionId. One thought is to grab something from the client side and pass into our initial request for subscribing to SignalR notifications. I was looking at these request cookies and wondered if there was something that I could use there.

Any thoughts on this?

Thanks, JohnB

No correct solution

OTHER TIPS

Instead of Sessions, SignalR makes use of Connections. According to the http://asp.net/signalr website, "Each client connecting to a hub passes a unique connection id. You can retrieve this value in the Context.ConnectionId property of the hub context. . . "

Also, the Context still has a User property, retaining the Identity (and thus username) of the user (Context.User.Identity.Name)

Therefore, instead of using Sessions, you can use ConnectionId's to identify users.

This page goes into more details: http://www.asp.net/signalr/overview/signalr-20/hubs-api/mapping-users-to-connections

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top