Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Ajax

Ajax: Fix a Long-Polling Request Piling Up Behind a Proxy Timeout

- 30.11.26 - ErcanOPAK

🔄 Fix a Long-Polling Request Piling Up Behind a Proxy Timeout

A long-polling request deliberately holds the connection open until the server has new data to send, sometimes for 30–60 seconds, but any reverse proxy sitting in front of the app (nginx, a load balancer, a corporate gateway) has its own default upstream read timeout — if that timeout is shorter than the poll duration, the proxy kills the connection first, the browser reports a generic network error, and the client’s retry logic immediately opens another long poll that hits the exact same timeout again.

🔎 The Problem

Client-side timeline:
  t=0s    Ajax long-poll request sent
  t=30s   nginx proxy_read_timeout fires, connection reset
  t=30s   XHR onerror fires, retry logic reopens the poll
  t=60s   same proxy timeout fires again
  (repeats indefinitely, server never got to actually answer)

✅ Fix: Align the Poll Duration With the Proxy’s Actual Timeout

  • Raise proxy_read_timeout (or the equivalent on whatever reverse proxy sits in front) to comfortably exceed the long-poll’s maximum hold duration, with margin for network jitter.
  • Alternatively, shorten the server-side poll’s own max wait time to safely undercut the proxy’s existing timeout, so the server always responds (even with an empty ‘no new data yet’ result) before the proxy gets a chance to cut the connection.
  • Have the client distinguish a proxy-timeout reset from a genuine server error in its retry logic, and back off briefly before reopening the poll instead of hammering the same timeout in a tight loop.

A long-polling request that keeps dying at the same elapsed time isn’t a flaky connection — it’s a proxy timeout that was never told how long the poll actually needs.

— Frontend Engineer

Related posts:

Ajax: Fix navigator.sendBeacon Silently Dropping a Payload Over 64KB With No Error Reported on Page ...

Ajax: Fix navigator.sendBeacon Silently Dropping a Payload Over 64KB With No Error Reported on Page ...

AJAX: REST API Security Best Practices

AJAX: REST API Security Best Practices

Ajax: Understand XMLHttpRequest for HTTP Requests

Ajax: Understand XMLHttpRequest for HTTP Requests

Views: 7
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

The AI Prompt That Plans a Kid’s Birthday Party on a Tight Budget

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 996 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 995 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 866 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 629 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 561 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com