Azure SignalR "Handshake Cancelled" Error During WebSocket Connection — How to Debug and Resolve?

Harish Gudella 0 Reputation points Microsoft Employee
2025-04-28T03:30:15.2+00:00

Hi everyone,

I'm facing an issue while connecting to Azure SignalR using a .NET 8 app. The connection consistently fails during the WebSocket handshake.


📋 Environment:

.NET Version: 8.0

Azure SignalR Client Library: Microsoft.Azure.SignalR

Transport Type: WebSocket

Network: Behind VPN / Corporate Proxy (may be influencing traffic)


🛠 Observations:

  • In Application Insights Live Metrics:
      vbnet
      CopyEdit
      StartConnectionFailed: Failed to start connection. Reason: Handshake cancelled.
    

Exception: Handshake cancelled. Transport: WebSocket Hub: serversenteventshub

  
- **In my application logs**:

  ```yaml
  pgsql
  CopyEdit
  Failed to connect to '(Primary)https://****-signalr.service.signalr.net(hub=Events)', will retry after back off period. Error: Unable to connect to the remote server. The base stream is not writable. 

🧩 Questions for the Community:

  1. What are best practices to debug "Handshake Cancelled" issues with Azure SignalR and WebSockets?
  2. How can I force full TLS handshake in .NET 8 (disable session resumption) for testing?
  3. What HTTP headers must be explicitly present during a WebSocket handshake to Azure SignalR service?
  4. Are there known issues with TLS 1.3 and Azure SignalR service when client is behind proxies?
  5. Any recommendations for diagnostic logging settings in .NET to capture more low-level networking errors.

Here is the live trace from Azure SignalRUser's image

.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,230 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 75,051 Reputation points
    2025-04-28T04:15:34.4066667+00:00

    You need to check that both the client and any proxy support TLS 1.3. You should get the client log if you can, it’s the one rejecting the connection.

    you can configure your clients signalr to fallback to long polling on the client side if websocket connection cannot be made.

    note: the browser will typically break the connection if not running in the active tab.

    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.