Azure PubSub Connection Timeout (ETIMEDOUT)

Ashir Baig 0 Reputation points
2026-01-22T08:36:42.56+00:00

I have provisioned an Azure Web PubSub service by following the official Azure documentation. The service has been configured using the JSON settings provided below. In addition, a secondary replica has been set up successfully, and its configuration details are also included.

Despite this setup, we are consistently encountering a connection timeout error (ETIMEDOUT) when attempting to connect to the Azure Web PubSub service. The issue occurs during client connection attempts and impacts message delivery.

This service is actively used in our production environment, and the timeout is causing service disruption.
Additional Technical Context:

  • Azure Web PubSub Service is deployed and running
  • Primary and secondary replicas are enabled
  • Error occurs during client connection attempts to the service endpoint
  • Error message observed: ETIMEDOUT
  • Configuration has been validated against Azure documentation
  • Application server load is within normal operating limits (CPU, memory, and network utilization are stable and not saturated at the time the issue occurs)

Please let us know if additional details required

Edited PII information

Azure Web PubSub
Azure Web PubSub

An Azure service that provides real-time messaging for web applications using WebSockets and the publish-subscribe pattern.


2 answers

Sort by: Newest
  1. Praneeth Maddali 12,670 Reputation points Microsoft External Staff Moderator
    2026-01-22T19:26:20.8566667+00:00

    Hi @Ashir Baig

    Thanks for clearly describing the issue. I understand that this timeout is impacting your production service, and it can be very frustrating, especially when everything else appears to be working well.

    Most Likely Cause:

    With replicas enabled, such as your secondary setup, clients should connect only to the primary endpoint: wss://connectlingua-jp-pubsub-prod.webpubsub.azure.com/client/hubs/myhub?access_token=...

    Connecting to the secondary replica endpoint (connectlingua-jp-pubsub-sec-prod) will always result in an ETIMEDOUT error.

    Quick Diagnostic Steps :

    1. Check the endpoint: Make sure your app code is using the primary FQDN above and not "sec-prod."
    2. Test connectivity: Try connecting from your client machine or server.
         npm install -g wscat
         wscat -c "wss://connectlingua-jp-pubsub-prod.webpubsub.azure.com/client/hubs/myhub?access_token=YOUR_TOKEN"
         
         
      
    3. Check networking: Portal >Web PubSub > Networking > Access Restrictions > Allow "All networks" temporarily
    4. Enable Live Trace: Portal >Monitoring > Live Trace >Enable > Try connecting >Check for events

    Expected Results:

    1. If wscat connects successfully, the endpoint is healthy — this means the issue is in your client application code. You should fix your app’s connection string.
    2. If wscat times out, there is a network blockage preventing the connection. You should check your firewall or proxy settings, especially ensuring port 443 is open.
    3. If Live Trace is empty, the request is not reaching Azure at all. This indicates a client-side network or proxy block, so review your network rules or proxy configuration.
    4. If Live Trace shows events, Azure is receiving the connection attempts. At this point, you should check your authentication token and application logs, because the issue is likely related to auth or app logic.

    Below are the most common reasons this occurs and how to isolate them.

    Reasons for Intermittent Connection Success and Timeouts Network Instability (firewall, proxy, VPN, ZTNA, TLS inspection): WebSockets need a steady outbound route over port 443. If a firewall or proxy sometimes delays or blocks the TLS/WebSocket handshake, those attempts may fail with ETIMEDOUT.

    Network access control & outbound requirements: https://learn.microsoft.com/azure/azure-web-pubsub/howto-secure-network-access-control Token Expiry or Reuse Under Load:

    If several clients use a short-lived or soon-to-expire access token, some connections may succeed while others fail at handshake. Authentication and token behavior: https://learn.microsoft.com/azure/azure-web-pubsub/howto-troubleshoot-common-issues#authentication-…

    Client-Side Connection Surges and Throttling:

    If many connections are started at once, handshake processes may slow down and hit timeout limits.

    Connection count / throttling rules https://learn.microsoft.com/azure/azure-web-pubsub/concepts-service-constraints

    Recommended Steps for Determining the Root Cause

    Conduct multiple connectivity tests using wscat from the same client environment

    This approach helps determine if the issue is related to the client network:

    Knowledge base

    npm install -g wscat
    wscat -c "wss://connectlingua-jp-pubsub-prod.webpubsub.azure.com/client/hubs/myhub?access_token=YOUR_FRESH_TOKEN"
    
    

     If the results are inconsistent, such as 5 out of 10 being successful, this indicates that the network path is unstable.

    Enable Live Trace and compare successful and failed attempts from Portal > Web PubSub > Monitoring > Live Trace

    Check for:

    • No events at all – the client did not reach Azure, possibly due to a network or proxy block
    • PingTimeout / SlowClient – handshake is taking too long on the client side
    • Authentication errors – token may be close to expiration

     Reference:

    https://learn.microsoft.com/en-us/azure/azure-web-pubsub/howto-troubleshoot-resource-logs  

    https://learn.microsoft.com/en-us/azure/azure-web-pubsub/howto-enable-geo-replication?tabs=Portal

    https://learn.microsoft.com/en-us/azure/azure-web-pubsub/howto-troubleshoot-common-issues

    https://learn.microsoft.com/en-us/azure/azure-web-pubsub/howto-troubleshoot-resource-logs

    https://learn.microsoft.com/en-us/azure/azure-web-pubsub/howto-secure-network-access-control?tabs=azure-portal

     Kindly let us know if the above helps or you need further assistance on this issue.

     

    Please "upvote" if the information helped you. This will help us and others in the community as well.

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-01-22T08:36:58.24+00:00

    The connection timeout error (ETIMEDOUT) you are experiencing when trying to connect to the Azure Web PubSub service can be caused by several factors. Here are some troubleshooting steps you can take to address this issue:

    1. Verify Connection String: Ensure that the connection string or fully qualified domain name specified when creating the client is correct. Any errors in the connection string can lead to timeouts.
    2. Firewall and Port Permissions: Check the firewall settings in your hosting environment to ensure that the necessary ports for Azure Web PubSub are open. The service typically uses ports 443 for WebSockets and 80 for HTTP.
    3. Network Configuration: Ensure that your network is not blocking specific IP addresses that are required for Azure Web PubSub. You may need to allowlist certain IPs to ensure connectivity.
    4. Proxy Configuration: If your application is behind a proxy, verify that the proxy settings are correctly configured. An intercepting proxy can cause SSL handshake failures, leading to connection timeouts.
    5. Service Status: Check the Azure service status to see if there are any ongoing issues or maintenance that could affect connectivity.
    6. Resource Logs: Utilize resource logs to identify any unexpected disconnection events or connection limits being reached. Look for entries like Connection count reaches limit or other relevant messages that could indicate issues.
    7. Client Performance: Ensure that the client is capable of handling the current traffic load. If clients are not able to process messages quickly enough, it may lead to timeouts.

    By following these steps, you should be able to identify the root cause of the ETIMEDOUT error and take appropriate action to resolve it.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

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