3

I have an asp.net core 3.1 web app that uses SignalR, and I'm experiencing weird repeating requests from my web clients, e.g.:

repeated requests illustrated

I have no idea why these are happening, AFAIK there isn't any code on the client side that should cause this. I've also asked my users and they also don't report anything weird on their end (e.g. browser auto-refresh). I'm hoping someone has seen similar events or has an idea what's the best way to debug this.

Update 1:

I tried the force long-polling strategy, couldn't repro the issue locally.

I added a few extra log variables, and apparently the body is empty, BUT all the weird requests are coming from Chromes running on Linux. I guess it's time to spin up a vm...

Tamás Deme
  • 2,194
  • 2
  • 13
  • 31

3 Answers3

1

Is it possible that your clients don't have available Web Sockets or Server Sent Events protocol and are using Long Polling fallback, having this function executed?

https://github.com/dotnet/aspnetcore/blob/9f96be478cc3b6f459899d795e9f8b7dadb20018/src/SignalR/clients/ts/signalr/src/Utils.ts#L93

Probably if you will temporarily make more detailed log to see which Json property names are sent, you can see if it is something similar to hub method invocation messages. Or you can also try to log user-agent header to check if browser of requesting client supports those protocols

Update:

Or probably you can test how long polling transport requests look like on your local, using code like this

var connection = new signalR.HubConnectionBuilder()
.withUrl("/chatHub", signalR.HttpTransportType.LongPolling).build();

enter image description here

this is how it looks on my local, type: 6 is ping request, as Brennan mentioned

Invocations looks like this:

enter image description here

Anton
  • 136
  • 1
  • 7
  • So as I added in "update 1" above, all the weird requests are coming from Chrome on Linux users. Is it possible that on linux websockets is disabled for some reason? – Tamás Deme Apr 20 '21 at 03:14
  • @TamásDeme sorry, i gave you wrong code example for ASP.NET Core 3.1, if you used it, it can be a reason why it wasn't the same on your local, updated the answer, sorry for Russian language in console. When you will try, make sure to disable cache if cache burst is off, i forgot about it when was testing that code :) Thats strange that there is no content, to find out if Web Sockets are available in that browser we probably will need browser version number, did you save it? – Anton Apr 20 '21 at 06:32
1

The client is sending pings at regular intervals. However, this is not needed when using LongPolling and has been fixed in 5.0.0.

https://github.com/dotnet/aspnetcore/pull/15352

Brennan
  • 1,834
  • 1
  • 7
  • 13
0

I figured out the issue (or at least this issue):

azure web app enable websockets configuration

If you don't enable websockets in the web app configuration, you clearly won't have websockets... ‍♂️

I'm leaving the question / answer up, just in case someone runs into the same issue. I guess this is as close as it gets to:

  • is it plugged in?

  • of course it is.

  • [narrator] it wasn't plugged in.

Thanks everyone for the helpful pointers either way! Also @Andy maybe check your configuration too :)

Tamás Deme
  • 2,194
  • 2
  • 13
  • 31