Why HTTP 28, HTTP 500 & HTTP 502 Cause Duplicate FBR Submissions — And How NANU Prevents It

Detailed explanation of common API errors that create invoice duplication, their root causes, and the architectural protections NANU Digital Invoicing uses to guarantee invoice uniqueness.

Submitting invoices to FBR’s IRIS requires a reliable API connection and correct payloads. When integration software does not handle API errors properly, organizations often see invoices submitted multiple times (duplicate IRNs, repeated buyer notifications, reconciliation headaches). Below we explain HTTP 28, HTTP 500 and HTTP 502, how they cause duplicates, and how NANU Digital Invoicing eliminates those failure modes with a robust safe-submit architecture.

What these errors mean (short)

HTTP 28 — Operation Timed Out

A client-side cURL timeout: the request took too long and the client closed the connection.

  • Causes: network latency, FBR slow response, large payload, temporary gateway slowness.
  • Typical software reaction: treat as failure and retry immediately.
  • Risk: FBR may already have processed the invoice but the response never returned to the client → duplicate submission on retry.

HTTP 500 — Internal Server Error

The server encountered an unexpected condition while processing the request.

  • Causes: FBR backend exception, malformed JSON, schema mismatch, server crash.
  • Typical software reaction: assume failure and resubmit the payload.
  • Risk: FBR may have partially processed the invoice or created records — resubmission causes duplicate IRNs or records.

HTTP 502 — Bad Gateway

A gateway or proxy between client and FBR failed or returned an invalid response.

  • Causes: gateway overload, routing issues, temporary WAF/Cloudflare problems.
  • Typical software reaction: immediate retry without verification.
  • Risk: invoice reached FBR but client did not receive a response → repeat submission.

How these errors lead to duplicate invoice submissions

Duplicate invoices are almost always caused by incorrect or naïve retry & error handling. Common patterns that create duplicates:

  • 1. Timeout illusion: The client times out (HTTP 28) and assumes the invoice was never received, so it retries. FBR may have already processed it.
  • 2. Server partial-accept: HTTP 500 or internal errors may occur after FBR has stored or partially processed the payload. A retry resends the same invoice.
  • 3. User retries: User sees no response and clicks submit multiple times.
  • 4. Blind retries: Automated retry systems that do not check transaction state before resubmitting.

Result: multiple IRNs, duplicated accounting entries, buyer confusion and difficult reconciliation work.

Detailed technical reasons behind these errors

Network & client-side issues

  • Short timeout settings: connect or overall timeout too small for FBR response times.
  • TCP/IP packet loss: intermittent packet drops causing partial responses.
  • Local resource saturation: high concurrency without connection pooling causes delays and timeouts.

Server & gateway problems

  • FBR backend overload: high peak traffic times cause slow processing or crashes.
  • Gateway/Proxy errors: misconfigured WAFs, reverse proxies, or CDN intermediaries can return 502.
  • Unhandled exceptions: malformed payloads or unexpected null values trigger 500 errors on server side.

How errors affect invoice data & duplication mechanics

When the same invoice payload is received multiple times by FBR (because of retries), potential outcomes include:

  • Multiple IRNs: FBR may create separate IRNs for repeated submissions, each treated as a separate record.
  • Accounting mismatches: Sales, stock, and tax ledgers may show duplicate entries that require manual correction.
  • Buyer confusion: Buyers can receive multiple invoices for the same sale leading to disputes.
  • Audit risks: Duplicate reporting raises red flags during audits and can cause reconciliation penalties.

A robust integration must therefore ensure idempotency — the guarantee that retrying a request does not create duplicate results.

How NANU Digital Invoicing fully prevents duplicate submissions

Safe-Submit Architecture™

NANU isolates invoice processing with an architecture that prevents duplicate transmission even under error conditions.

  • Invoice isolation & locking: On submit, NANU locks the invoice record so no concurrent or repeated submissions can proceed.
  • Unique transaction fingerprint: Every submission gets a unique ID and hash. Retries are checked against fingerprints before any re-send occurs.
  • Idempotent safe-checks: Before retrying, NANU queries the last-known transaction state and FBR (if necessary) to confirm whether an IRN already exists.

Intelligent error handling & recovery

  • Timeout-aware retries: For HTTP 28 (timeout), NANU performs a controlled verification rather than blind resubmit.
  • Partial-result detection: For HTTP 500/502, NANU checks transaction logs, performs safe queries, and only resends if safe.
  • Rate limiting & backoff: Retries use exponential backoff to reduce load on FBR and avoid gateway errors.

Result: One invoice → One IRN. NANU guarantees invoice uniqueness even when FBR or network issues occur.

Practical recommendations for integrators & dev teams

  1. Set sensible timeouts: short connect timeout (5-10s), longer read timeout (60–80s) for FBR endpoints.
  2. Implement request fingerprinting: include invoice number + hash + timestamp as a unique key.
  3. Use idempotency keys: store and check keys before any resend.
  4. Apply exponential backoff for retries and respect server response headers (Retry-After).
  5. Log all transactions deterministically: store payload, response (or lack of), and timestamps.
  6. Provide clear UX: show “processing” states and prevent multiple clicks. Offer a status lookup rather than blind repeat submit.

Need guaranteed, duplication-free FBR invoicing?

NANU Digital Invoicing isolates invoice data, manages timeouts and retries safely, and ensures every invoice receives exactly one IRN — even in the face of HTTP 28/500/502 errors.

View Quick Demo View Pricing