Reputation: 8937
Can you discern on the server side which transport method is being used for a given SignalR connection? (WebSockets, SSE, long polling, etc.?)
Upvotes: 17
Views: 4156
Reputation: 1999
For ASP.NET SignalR version 2.0, you can use $.connection.hub.transport.name
to print out the name of the transport. It will evaluate to "serverSentEvents" and other transports.
Upvotes: 6
Reputation: 15244
Inside a Hub you can detect the transport being used by looking at the request's query string:
Context.QueryString["transport"]
This will evaluate to "webSockets", "serverSentEvents", "foreverFrame" or "longPolling".
Ideally your code should not depend on which transport is being used since SignalR abstracts that for you. However, this could be useful for logging and such.
Upvotes: 19