Nonce and subscription problems behind a Besu RPC load balancer

Applications that spread Besu JSON-RPC calls across several nodes can get wrong nonces and miss events. This page explains the causes, the load balancer and application fixes, and how to recover dropped subscriptions.

On this page

Why a Besu RPC load balancer causes wrong nonces and missed events

When an application sits behind a Besu RPC load balancer and sees duplicate or rejected transactions, or gaps in its event stream, the cause is almost always state that lives on each individual node, not Besu failing. Each Besu node keeps its own transaction pool, and each node holds its own subscription and filter state, so a request that depends on that state can return different answers depending on which node the load balancer picks.

Teams usually add several RPC nodes for availability, so that one node can be restarted, upgraded or lost without taking the application offline. That design is sound, but it changes the contract the application relies on. A nonce request for one account may be answered by a node that has not yet seen the application's last submitted transaction, and an event subscription opened on one node does not follow the application to another. Before changing anything, confirm which RPC methods your application calls, whether it sends transactions from the same account through more than one node, and whether it subscribes to events or polls with filters over HTTP.

This page covers the fixes in order: how readiness checks decide which nodes receive traffic, when sticky sessions per account or per connection are enough, when nonces should be tracked outside Besu, and how to recover events after a subscription drops. Each step depends on the answers to those three questions, so start by checking your application's calls against the Besu high availability documentation.

Which fix fits which application pattern

This table compares the four fixes for nonce and subscription problems behind a Besu RPC load balancer: external nonce tracking, sticky sessions per account, WebSocket Pub/Sub and HTTP filters with sticky mode. Read each row against your application's write and event patterns, then check the cost and the gap each fix leaves open.

FixWhen it fitsComplexity you take onWhat it does not solve
Track nonces outside BesuApplications that send many transactions from the same account and need a single source of truth for the next nonceYour application or a shared service must assign, persist and recover nonces, and reconcile them after failed or dropped transactionsGaps left by transactions that never reach the pool, and stuck or replaced transactions, still need handling
Sticky load balancing per accountClients that submit transactions for one account in sequence and can route all of that account's requests to one nodeLoad balancer rules must hash on the account or session, and failover must be planned for when the pinned node goes downIt does not make nonce reads consistent across nodes, and a node that lags can still return stale counts after failover
RPC Pub/Sub over WebSocketApplications that need live event or pending transaction notifications and can hold a long-lived connection to one nodeClients must detect dropped connections, resubscribe and backfill missed events on reconnectA dropped connection still loses events in the gap, and it does not help applications that only use HTTP
HTTP filters with sticky modeLegacy clients that poll with filter IDs over HTTP and cannot move to WebSocketLoad balancer stickiness must be configured and tested, and filters expire or disappear if the node restartsFilter state is lost on failover, so polling clients still need a recovery path using block and log queries

Configuring readiness checks, stickiness and subscriptions

This sequence makes a Besu RPC load balancer send traffic only to synced nodes, keeps each account's nonce-sensitive writes and each subscription on a predictable path, and gives the application a tested way to recover events after a node fails.

  1. Define a readiness check that tests sync state

    The platform team adds a health check in front of each Besu RPC node that calls the JSON-RPC endpoint and fails the node when it is not in sync with its peers. A node that is up but behind the chain can return stale nonces and missing logs, so a plain TCP or port check is not enough. Confirm the check by stopping block import on one test node or by pointing it at a lagging peer set, then verifying the load balancer removes it from rotation within your configured check interval and restores it after catch-up.

  2. Choose the stickiness rule for each traffic type

    The application team separates its traffic into two groups. Nonce-sensitive writes need affinity per sending account, so every transaction from one account reaches the same node. Subscriptions need affinity per connection, because a WebSocket stays with one node for its lifetime. Write the rule down per route in the load balancer configuration and confirm with a test: send three transactions from one account through the balancer and check that the requests land on the same backend node in the access logs.

  3. Decide where the nonce counter lives

    The application owner chooses between two designs. Sticky routing per account lets Besu's own pool answer the nonce query, but it depends on the routing rule holding through failover. Tracking the nonce in the application or a small shared store removes that dependency, but the team must own its seeding and reconciliation. Seed the counter from the latest on-chain count for each account, then reconcile it against the pending count and against any transaction that reports an error. Confirm the design by submitting a burst from one account across a forced node restart and checking that no nonce is reused or skipped.

  4. Move subscriptions to Pub/Sub over WebSocket

    The integration team switches event consumers to RPC Pub/Sub over WebSocket, which Besu recommends for subscriptions because the connection stays with one node. If a client must use HTTP filters, enable sticky mode for those routes instead, since filter IDs exist only on the node that created them. Confirm the change by opening a subscription, emitting a test event, and checking that the event arrives once and that a filter created over HTTP still returns results on the next poll.

  5. Build the gap recovery procedure after a dropped subscription

    The application team writes a recovery routine that runs when a subscription drops. It reads the last processed block, then uses eth_getBlockByNumber to walk block headers forward, eth_getLogs to fetch the logs for the missed range, and txpool_besuTransactions to review pending transactions. Store the last processed block only after the event is handled, so the replay cannot skip work. Confirm the routine by disconnecting a consumer during a known test transaction and checking that the replayed events match the events a healthy consumer received.

  6. Run a failover drill on a test network

    The operations team stops one RPC node while a load generator submits transactions from several accounts and holds an open subscription. They observe whether the balancer removes the node, whether affected connections reconnect and resubscribe, and whether the nonce sequence stays continuous. Record each failure and the time it took the balancer to react, then confirm the fixes with a second run. Ask your vendor or your own test team to document the expected failover behavior for your chosen load balancer before the drill begins.

  7. Repeat the drill after each Besu upgrade

    The platform team reruns the readiness, stickiness and recovery checks after each Besu upgrade and after any change to the load balancer or node configuration. This catches changes in endpoint behavior, authentication settings or pool handling before production traffic does. Keep the results with the change record so the next reviewer can see which checks passed for that version. Check that the drill passes on the new version in the same environment before the upgrade reaches production.

How nonce and subscription requests move through the load balancer to Besu nodes

The diagram starts with the application, which sends reads and writes through a load balancer that only forwards to Besu RPC nodes passing a readiness check. Nonce requests can be routed per account through an external nonce store, while WebSocket subscriptions stay pinned to one node. When that connection drops, the application re-reads block headers, logs and pending transactions from a healthy node before resuming. Check that each node answers readiness and that the nonce store is the only source of sequence numbers.

Request paths, nonce tracking and subscription recovery across Besu RPC nodes.

Recovering missed events after a dropped subscription

Block headers are the simplest events to recover because every block has a height that increases by one. After a dropped subscription, the application reconnects, reads the current head from the node it reaches, and fetches each missing header with eth_getBlockByNumber. The application needs to remember the last height it fully processed, not only the last notification it received, so that a header that arrived but was never processed is fetched again.

  • Last processed height: Save the block number only after your downstream write has committed, so a crash between receipt and processing cannot skip a block.
  • Gap fill order: Request each height from the stored value plus one up to the head, in ascending order, and stop when a fetch returns no block because the node may still be catching up.
  • Hash comparison: Store the hash at each height. If a refetched header has a different hash, treat it as a reorganization and roll back the records written for the affected heights before continuing.
  • Head source: Read the head from the node you reconnect to, since a lagging node can report an older head.

Confirm how far back your nodes keep the blocks you need, because pruning and storage settings set the earliest height you can refetch. The Besu high availability documentation is the starting point for that check.

Security and operational risks at the load balancer and RPC layer

Putting several Besu RPC nodes behind a load balancer adds a shared entry point that carries credentials, transaction traffic and readiness decisions. The cards below cover the controls that keep that entry point from becoming the weak point in nonce tracking and subscription recovery.

RPC authentication on every node

Besu can require a username and password credentials file or accept externally issued JWTs validated against a public key. Decide which method your applications use, then confirm that each node in the pool enforces the same setting. A node that accepts unauthenticated calls can receive transactions and subscription requests that bypass the controls on the rest of the pool. Test each node directly, not only through the load balancer, to confirm rejections happen everywhere.

Besu authentication docs

HTTPS termination in front of Besu

Besu does not terminate HTTPS natively, so TLS has to be handled by the load balancer, a reverse proxy or a gateway you operate. Check where the connection is encrypted and whether traffic between the proxy and each Besu node also uses protected transport. Confirm certificate renewal, cipher policy and which headers the proxy forwards, since JWT validation and access logs depend on them.

Exposing RPC to approved callers only

Limit which networks and services can reach the RPC ports on each node and on the load balancer. Application servers, indexers and monitoring tools should each have a named path, and admin namespaces should stay off the shared pool. Review firewall rules whenever a new application is onboarded, because a single broad allow rule defeats the per-account nonce design.

Nonce store integrity and access

If applications track nonces outside Besu, that store becomes a transaction-ordering control. Restrict who can write to it, log each allocation, and make sure a restart or failover cannot reissue a nonce already in the pool. Test what happens when two workers request the same account at the same moment, and confirm the store is backed up alongside the rest of your application data.

Node sync monitoring through Besu metrics

Besu exposes Prometheus metrics when started with --metrics-enabled, on port 9545 by default. Alert on how far each node's chain head lags its peers, on peer count, and on the health of the transaction pool, since a lagging node is the most common source of stale nonce and missed-event results. Keep the metrics endpoint off the public network and confirm your scrape path reaches every pool member.

Besu metrics docs

Change control for readiness rules

Health-check thresholds, sticky session settings and pool membership all change how requests are routed. Treat them as configuration under version control, with a named owner and a review before each change. Record which nodes were in the pool when an incident occurred, because a loosened readiness rule can send traffic to a node that is still catching up.

Questions teams ask before fixing RPC load balancer nonce and subscription issues

Can our own team fix nonce and subscription problems behind a Besu RPC load balancer?

Yes, if your engineers can read node logs, change load balancer rules and modify the application code that sends transactions and opens subscriptions. The fixes themselves are not exotic: add a readiness check that reflects node health, choose sticky routing per account or move subscriptions to WebSocket, track nonces in a component you control, and recover missed events after a disconnect. The harder part is confirming that every application path follows the same rules. Teams with few applications and a clear owner for the transaction path often handle this in house. Teams with many services that each manage their own signing and event handling usually benefit from an outside review of the full call pattern. Confirm your team's capacity against the Besu high availability guidance before deciding.

What makes this work larger or smaller in effort?

Three factors drive effort most. The first is the number of applications that submit transactions or read state, since each one may track nonces or hold subscriptions differently. The second is the number of Besu RPC nodes behind the load balancer and how they are configured, including whether readiness checks already exist. The third is the subscription pattern: applications that rely on filters over HTTP need sticky routing, while applications using WebSocket Pub/Sub need reconnect and recovery logic. Applications that write to the chain from several services at once add coordination work, because the nonce source must be shared. A fixed-scope written plan should list each application, each node pool and each subscription type so the effort can be sized from a known inventory.

What do we need to provide from our team?

Plan for three groups of people to be available. Node operators need read access to Besu logs, metrics and configuration on each RPC node, plus the ability to restart nodes in a controlled window. Load balancer administrators need to review and change health checks, routing rules and session persistence, and to confirm how those settings behave under failover. Application code owners need to identify where transactions are built, where nonces come from, and where subscriptions are opened and closed. Without the code owners, the nonce fix cannot be verified, and without the load balancer administrators, the routing change cannot be tested. A test environment that mirrors the production topology is also useful, so changes can be checked before they reach live traffic.

How long does this kind of fix take?

Duration depends on scope, so it must be quoted from a written plan rather than assumed. The schedule is shaped by how many applications and node pools are involved, how much testing a non-production environment allows, and how quickly your change process approves routing and application changes. Ask any provider, including DeployOpen, to break the timeline into discovery of the current call pattern, design of the routing and nonce approach, implementation in each application, verification under failover, and handover of runbooks. Each phase should name the people it needs from your side, so delays in access or approvals are visible early.

Should we stop using a load balancer in front of Besu RPC nodes?

No, not in most cases. A load balancer provides a single endpoint, lets you remove unhealthy nodes from rotation and supports maintenance without downtime. The problems in this topic come from routing requests for the same account to different nodes with different transaction pools, and from subscriptions that stay attached to one node but are reconnected elsewhere. Those issues can be addressed with sticky routing per account, readiness checks, a nonce source outside Besu and WebSocket subscriptions with recovery. Removing the load balancer shifts the work to each application, which then has to choose a node and handle failover itself. Keep the load balancer unless your analysis shows that the routing rules cannot be made to match your application patterns.

What should a quote for this work include?

A useful quote is tied to a written scope. It should list the applications and transaction paths in scope, the Besu RPC nodes and load balancer configuration covered, the subscription types that need recovery logic, and the test environment used for verification. It should state the deliverables, such as updated readiness checks, routing rules, application changes, a nonce tracking design, recovery procedures and runbooks. It should separate one-time work from anything recurring, such as ongoing support or retesting after Besu upgrades. Ask which items depend on your team's access and approvals, and what happens to the schedule if they are late. DeployOpen does not publish a price list, so a quote follows from the written scope.

Will the fix prevent every wrong nonce or missed event?

No provider can promise that outcome. What the work can do is reduce the paths that produce wrong nonces and missed events, make the remaining failure modes visible, and give operators a tested recovery procedure. Verification should include failover tests while transactions and subscriptions are active, checks that nonces match the expected sequence after node changes, and confirmation that missed events can be recovered with the Besu methods named in the vendor guidance. Ask for the test cases and their results as part of the handover, so your team can rerun them after future changes.

How DeployOpen scopes and delivers Besu RPC fixes

DeployOpen starts by mapping which applications send transactions and subscribe to events through the load balancer, then agrees the fix in writing before changing anything. The work covers load balancer health checks, session routing, nonce tracking and subscription recovery, tested against your own nodes in infrastructure you control.

How we scope

  • Inventory every application that sends transactions or opens filters and subscriptions through the RPC endpoint
  • Record how the load balancer routes requests today, including health checks and session behavior
  • Agree in writing which nonce, sticky routing and recovery changes are in scope and how they will be tested
  • Confirm which Besu versions, deployment tools and monitoring stacks the fix must fit

How we build

  • Configure readiness checks so the balancer removes nodes that are syncing or lagging before they serve reads
  • Set routing per account or move subscriptions to WebSocket Pub/Sub so each client stays on one node
  • Add or adjust a nonce tracking service outside Besu where applications submit transactions concurrently
  • Build recovery jobs that backfill headers, logs and pending transactions after a dropped subscription

How we hand over

  • Provide runbooks for the load balancer rules, nonce service and recovery procedure with named owners
  • Deliver test evidence showing nonce gaps and missed events are caught under concurrent load and node restarts
  • Document configuration in your repository so changes go through your normal review process
  • Walk your platform and application teams through failure cases and the checks they should watch

How we support

  • Fixed-scope engagements have written deliverables, timelines and acceptance criteria agreed before work starts
  • Ongoing support, upgrades and continuous testing are available as a retainer, scoped separately
  • Ask any quote to itemize the balancer, application, testing and handover work so you can see what recurs
  • Plan retests after each Besu upgrade, since routing and subscription behavior should be rechecked on new releases

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.