Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure SignalR Error: (429) Too Many Requests

I am using Azure SignalR with Asp.Net MVC API (with .net framework not .net core) project. I can never connect to Azure's SignalR service (tried any possible configuration) while everything works fine when signalr is self-hosted.

As I enable CLR exceptions (under Exception Settings pane by checking everything under Common Language Runtime Exceptions) I keep getting the two following errors:

1. System.Net.WebException: 'The remote server returned an error: (429) Too Many Requests.'

2. System.Net.WebSockets.WebSocketException: 'Unable to connect to the remote server'. Inner Exception WebException: The remote server returned an error: (429) Too Many Requests.

I am using SignalR Free tier but also tried with Standard tier and ended up with the same results.

I keep checking "Connection (max)" graph under "Overview" tab on Azure portal and observing "Server 20, client 0" all the time.

The first time I got the error I assumed I really tried connecting too many times and reached maximum connection/attempt and gave up trying. After some time (approximately 24 hours) I only tried three times and still getting the same exception (429 - too many requests).

This is my configuration (in Startup.cs):

app.MapAzureSignalR(
                "/signalr",
                GetType().FullName,
                new HubConfiguration
                {
                    // tried all combinations of boolean values below.
                    EnableDetailedErrors = true,
                    EnableJSONP = true,
                    EnableJavaScriptProxies = true
                }, options =>
                {
                    options.ConnectionCount = 5; // tried increasing and decreasing that number.
                    options.ConnectionString = "<my connection string from azure portal signalr service>";
                    options.AccessTokenLifetime = TimeSpan.FromDays(1); // tried even removing.
                }
            );

This code runs on my local machine, not on Azure's AppService. However, it won't run on AppService either. Because it is easier to debug on local machine, I have been trying on local machine.

I searched on the internet but have not found anything related to my issue.

How do I solve the problem?

EDIT: I have the following packages installed.

<package id="Microsoft.AspNet.SignalR" version="2.4.1" targetFramework="net472" />
<package id="Microsoft.AspNet.SignalR.Core" version="2.4.1" targetFramework="net472" />
<package id="Microsoft.AspNet.SignalR.JS" version="2.4.1" targetFramework="net472" />
like image 310
JustWork Avatar asked May 17 '19 12:05

JustWork


People also ask

How many clients can SignalR handle?

IIS on client operating systems has a limit of 10 concurrent connections. SignalR's connections are: Transient and frequently re-established. Not disposed immediately when no longer used.

How many users can SignalR support?

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 long do SignalR connections stay open?

The default keepalive timeout period is currently 20 seconds. If your client code tries to call a Hub method while SignalR is in reconnecting mode, SignalR will try to send the command.

Does SignalR need SSL?

If your SignalR application transmits sensitive information between the client and server, use SSL for the transport.


1 Answers

Edited:

How many hubs defined in your server-side? The server connection count for AspNet SignalR is (hub count + 1) * options.ConnectionCount


For Free instances, there are 2 dimensions of limits:

  1. Concurrent connection count <= 20
  2. Total message count sent per day <= 20K (refreshed every day at 12:00am UTC time).

There is no message limit for Standard tiers.

Here is the pricing detail for Azure SignalR Service. Here explains in detail how messages and connections are calculated.

like image 147
vicancy Avatar answered Oct 24 '22 00:10

vicancy