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" />
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.
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).
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.
If your SignalR application transmits sensitive information between the client and server, use SSL for the transport.
Edited:
How many hub
s 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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With