SignalR (Azure). Determine reason of why user got disconnected - azure

We have SignalR service hosted on Azure.
For technical reasons, it is essential for us to maintain as stable connection between client and host as possible. And what is happening is that at relatively random intervals some clients got disconnected. We know that this is not related to internet connectivity on the clients's side.
So, the question is, how we can determine reason of a disconnect.
Our SignalR hub implements overrides 'OnDisconnectedAsync'. And this method has 'Exception exc' parameter. Unfortunately every time it get's triggered, exc is always null (I was hoping to find details for disconnect there).
Additional details:
We user following SignalR packages on Server side:
Microsoft.AspNet.SignalR (2.4.0)
Microsoft.Azure.SignalR (1.0.5)
On client side we use "Microsoft.AspNetCore.SignalR.Client.Core" (1.1.0)
Also, we checked and we have enough resources on Azure SignalR (units)
Here are logs when user gets disconnected (happen after OnDisconnectedAsync):
2020-03-15 11:38:07.391 +00:00 [Debug] Microsoft.AspNetCore.SignalR.HubConnectionHandler: OnConnectedAsync ending.
2020-03-15 11:38:07.391 +00:00 [Debug] Microsoft.Azure.SignalR.ServiceConnection: Sending close connection message to the service for GFf8suySt2eMsOCLuYg0-wbb16618b1.
2020-03-15 11:38:07.391 +00:00 [Debug] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Received message from application. Payload size: 36.
2020-03-15 11:38:07.393 +00:00 [Debug] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Message received. Type: Binary, size: 37, EndOfMessage: True.
2020-03-15 11:38:07.393 +00:00 [Debug] Microsoft.Azure.SignalR.ServiceConnection: Received 37 bytes from service 12aa875c-a5b6-4842-8bc1-2d67e7ab30f6.
2020-03-15 11:38:07.393 +00:00 [Debug] Microsoft.Azure.SignalR.ServiceConnection: Connection GFf8suySt2eMsOCLuYg0-wbb16618b1 ended.

When the client is connected to the Azure SignalR, the persistent connection between the client and Azure SignalR can sometimes drop for different reasons. This section describes several possibilities causing such connection drop and provides some guidance on how to identify the root cause.
Possible errors seen from the client-side:
The remote party closed the WebSocket connection without completing the close handshake
Service timeout. 30.00ms elapsed without receiving a message from service.
{"type":7,"error":"Connection closed with an error."}
{"type":7,"error":"Internal server error."}
Root cause:
Client connections can drop under various circumstances:
When Hub throws exceptions with the incoming request.
When the server connection the client routed to drops, see below section for details on server connection drops.
When a network connectivity issue happens between client and SignalR Service.
When SignalR Service has some internal errors like instance restart, failover, deployment, and so on.
Please refer to https://github.com/Azure/azure-signalr/blob/dev/docs/tsg.md#client-connection-drops

Related

Azure Devops Service Hooks (Webhook) fails with The underlying connection was closed: An unexpected error occurred on a send

I've configured a service hook -> webhook that invokes a remote HTTPS URL with a valid certificate.
When testing the webhook I get this error:
There was an error sending the request, so there was no response.
Error(s):
An error occurred while sending the request.
The underlying connection was closed: An unexpected error occurred on a send.
You may not call this function on a different context than the original request
Invoking the same URL with curl everything is fine.
EDIT: Reading answers with a similar error I thought the problem could be related to the TLS version used by Azure Devops.
My remote service was enabled for TLS 1.3 and 1.2 and failed with <= 1.1.
I configured it to allow TLS 1.0 and 1.1 as well and I keep getting the same error.
I had checked "Accept untrusted SSL certificates". Unchecking it fixed the problem.

Azure Relay Hybrid connection - HTTP protocol vs WebSockets

Using "Azure Relay Hybrid Connection" while sending and receiving messages using the websocket protocol, if there is delay in receiving the response no exception occurred.
But when sending and receiving messages to "Azure Relay Hybrid Connection" using HTTP protocol and if there is more than 60secs delay in receiving the response, error response received which says 504 Gateway Time-out exception & exception message says "The request was routed to the listener but the listener did not respond in the required time', Why??
Since it is HTTP protocol, it can't be keep the connection open forever like websocket?
In "Azure Relay Hybrid Connection" while using HTTP protocol, by default 'Gateway Time-out' is 60secs, how to extend the default timeout duration?
Timed-out requests can be retried?

New Azure AD Connect Cloud agent status inactive

Installed 2 different member servers with Azure AD Connect cloud agents both have an inactive status.
I confirmed;
Both installs complete successfully
Proxy settings are off
Since the Azure port test URL is no longer working I manually tested several of the URLs listed on https://learn.microsoft.com/en-us/azure/azure-portal/azure-portal-safelist-urls?tabs=public-cloud, they were working
Here is a snippet from the local/server logs;
AADConnectProvisioningAgent.exe Error: 0 : Service bootstrap request failed with exception: 'System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at https://[UUID].syncfabric.bootstrap.his.msappproxy.net/ConnectorBootstrap that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStreamAsyncResult.CompleteGetRequestStream(IAsyncResult result)
When it says "the remote server returned an error: 407 proxy authentication", is that MS end or our end?
After trying numerous updates to the machine.config file, as with most MS products there are 100 different options to "try" to get the proxy settings right. None worked even after restarting the service.
We eventually gave up on that and manually set the proxy itself to allow the Azrue AD agent computer/IP to skip/bypass authentication and it connected successfully.

Creating Azure Event Grid webhook subscription fails TLS handshake

Trying to create a webhook subscription to an Event Grid topic fails with an error reported in the Azure portal:
Deployment has failed with the following error..."Webhook validation handshake failed for https://xxx.xxx.xxx.xxx:10443/event. Http POST request failed with response code Unknown
My webhook is a .NET core test app using a Kestrel server. I can see from logging that there is an incoming connection from Azure when I try to create the subscription, but this is immediately followed by a disconnect.
Microsoft.AspNetCore.Server.Kestrel: Debug: Connection id "0HMCE876DPTD6" accepted.
Microsoft.AspNetCore.Server.Kestrel: Debug: Connection id "0HMCE876DPTD6" started.
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets: Debug: Connection id "0HMCE876DPTD6" received FIN.
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets: Debug: Connection id "0HMCE876DPTD6" sending FIN because: "The client closed the connection."
Microsoft.AspNetCore.Server.Kestrel: Debug: Connection id "0HMCE876DPTD6" disconnecting.
Microsoft.AspNetCore.Server.Kestrel: Debug: Connection id "0HMCE876DPTD6" stopped.
It appears that there is an error during the TLS handshake. Are there any specific requirements for TLS for the webhook. I'm using the default certificate ("ASP.NET Core HTTPS development certificate"). This won't be trusted by Azure - is that a problem?
As per the documentation Using self-signed certificates for validation isn't supported. You need to use a signed certificate from a commercial certificate authority (CA) instead. You can also go through this troubleshooting document if it helps.

Why am I getting connection error on calling notify on Azure SignalR

I have configured a SignalR resource on my Azure account and am sending a message to the SignalR Hub using the below snippet in an Azure Function written in C#:
await signalRMessages.AddAsync(new SignalRMessage()
{
Target = "notify",
Arguments = new object[] { requestBody }
});
However, I keep getting the below error.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I have also verified that the Azure function URL for negotiate function returns me the below information as expected.
{"endpoint":"https://xxxxxxx.service.signalr.net:5001/client/?hub=broadcast","accessKey":"yyyyyyy"}
Why am I getting the connection error and what could I change in my configuration?
This error means no server listening at specified ip/port that you are trying to connect to. It can be caused by using the wrong IP address or the wrong PORT.

Resources