KRoy
KRoy

Reputation: 345

Does the Signalr server send all pending requests as a single response to poll, while on longpolling?

We are getting pending requests for a signalr client, bunched as an array in a poll response, like below:

{"C":"s-0,9E632",
"M":[
84
{"H":"MyHub","M":"SetSomething","A":[{"myProp1":"setting","myProp2":59.0}]}
1,
84
{"H":"MyHub","M":"SetSomething","A":[{"myProp1":"setting","myProp2":60.0}]}
1,
84
{"H":"MyHub","M":"SetSomething","A":[{"myProp1":"setting","myProp2":61.0}]} 
1,
84
{"H":"MyHub","M":"SetSomething","A":[{"myProp1":"setting","myProp2":62.0}]}
1,
6b
{"H":"MyHub","M":"SetMore","A":[{"myProp3":"Somestring","myProp4":0}]}
2
]}

Generally a single response to a poll comes like below:

{"C":"s-0,9E621","M":[
6b
{"H":"MyHub","M":"SetSomething","A":[{"myProp1":"setting","myProp2":59.0}]}
2
]}

I believe the ring buffer stores messages upto the DefaultMessageBufferSize limit, and would be sending those messages to the client when polled for it. My question is would they be sent one by one, like a queue, one response to one poll or all messages sent together as a response to the first poll (like we are getting, mentioned above)?

Background and actual issue: We have a signalr client(C1) working on longpolling and our SignalR server in the cloud. There is a user(U1) who connects to the server and sends messages for C1 and we forward those messages to C1 using Clients.User({C1}).{Method} on the server. When U1 sends multiple quick requests to C1, and C1 is unable to process them quickly enough, we see the bunched response sent to C1. C1 is not configured to handle the bunched response, and it rejects that response and we see a unending loop of the same bunched response to C1 from the server for every further poll.

Would appreciate any insights into this. Thanks in advance.

Upvotes: 1

Views: 696

Answers (1)

S M Abrar Jahin
S M Abrar Jahin

Reputation: 14588

Regarding this question's answer, firstly SignalR will never connect by default in long pooling.

Working procedure for SignalR-

  1. It tries to connect with WebSocket.

  2. If it can't connect, then it tries to connect with server-sent events.

  3. Even if it fails, then it tries with server frame.

  4. Even it fails, it uses long polling as a fallback.

More can be found here.

And regarding its performance, you can find more in here.

So, it is tested that SignalR can handle as many requests as a network device can handle, so there is almost no limitation regarding data transfer.

Your question's answer-

In your case, there we need to check few things.

  1. Is HTTPS is enabled? If not, please follow this link to setup HTTPS because, without HTTPS, you will never be able to use WebSocket and it is recommended.

  2. If HTTP is enabled, then it should communicate with WebSocket where this kind of issue will never happen if the network is OK. But for your case, I think, there is some problem with your network so that some data is missing, that's why it is sending too much data at once.

  3. Please check your timeout config for signalR. You can try changing timeout settings for SignalR.

I think, if you follow these 3 things, you could find the solution for your problem.

Upvotes: -1

Related Questions