Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does SignalR decide which transport method to be used?

SignalR is an abstraction over transports used for real-time connections. Still I'd like to know how exactly it decides which transport methods should be used, depending on various factors. I did some research using available documentation and looked into sources and came up with an idea how it works.

So my actual question would be, is the following flowchart correct or am I missing anything?

Flowchart of SignalR's assumed transport negotiating

Update:

Thanks for your input! Here is an updated version according to your fixes. But I'm still not sure about one thing: if there is no explicit check whether IE9+ is used, what triggers the fallback from ForeverFrame to LP if it's not IE and does not support SSE?

enter image description here

like image 364
thomaswr Avatar asked Jun 07 '13 11:06

thomaswr


People also ask

How does a SignalR work?

SignalR uses hubs to communicate between clients and servers. A hub is a high-level pipeline that allows a client and server to call methods on each other. SignalR handles the dispatching across machine boundaries automatically, allowing clients to call methods on the server and vice versa.

How many connections can SignalR 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).

How do I send client specific messages using SignalR?

We change the BroadcastChartData() method to accept connectionId as an additional parameter. This way, we can find the client using the connectionId and send a message just to that client. Additionally, we add a new GetConnectionId() method, which returns the connectionId of the client.

What protocol does SignalR use?

SignalR by default uses the WebSocket transport protocol in managing realtime communication between server and client, but if for some reason the client or server does not support WebSocket, then SignalR falls back to using Server-Sent Events or Long Polling.


1 Answers

Awesome diagram first off.

It's very close! Here's some fixes:

Configured JSONP
 Yes -> Use LP  
 No -> IsCrossDomain  
       Yes -> CORS Support?  
              No -> JSONP = true  
                    -> Use LP  
              Yes -> Server Supports WebSockets  
                     Yes -> Client Supports WebSockets  
                            Yes -> Use WebSockets  
                            No -> Use LP  
                     No -> Use LP  
              No -> Use LP  

One other slight detail: ForeverFrame is always tried before SSE (even in Chrome) but within the transport itself it checks if EventSource (the underlying method of SSE) exists, if it exists then the forever frame fails to start (so that it can fall back to SSE). Therefore IE9+ is never a direct check.

With my fixes implemented your diagram would then be accurate.

like image 90
N. Taylor Mullen Avatar answered Oct 04 '22 14:10

N. Taylor Mullen