For a dApp choosing an RPC transport, use HTTP for reads and transaction submission, and add WebSocket only when live block or log updates need push delivery.
Both transports carry JSON-RPC calls. HTTP gives each call a request and response; WebSocket keeps a connection open for node notifications. In ethers or viem, choose per feature: a balance screen, transaction button, and event feed can use different transports.
Latency and hosting decide whether a persistent connection helps
Latency and hosting decide whether your dApp benefits from a persistent WebSocket connection. Balances, allowances, and receipts each need one answer. HTTP fits: failed reads retry cleanly, block-specific results can be cached, and load balancers or serverless handlers can handle calls without keeping a process alive.
Live data changes the timing. HTTP needs polling: check the latest block, then fetch matching logs or state when it advances. WebSocket lets a node push a new header or matching log. The eth_subscribe method requires WebSocket or IPC, as Geth's subscription documentation explains. HTTP cannot deliver that subscription. Push reduces the delay after a node observes an event; it does not make a mined log available before its block. Measure the delay from the block reaching your RPC to the UI update; network and rendering time may dominate.
Take two clients watching the same contract event on the same chain and provider. One displays swaps in an activity panel; the other triggers a bot when a log arrives. The panel can poll eth_getLogs each block and usually look current to its reader. The bot values the time before its next poll, so WebSocket earns its overhead. The deciding difference is latency tolerance.
That overhead is operational. Browsers suspend tabs, proxies close idle sockets, and deployments restart processes. A WebSocket consumer must detect disconnection, reconnect, recreate subscriptions, and recover missed events. Reopening a socket alone only restores future delivery.
Assign HTTP and WebSocket to the features that need them
HTTP wins for ordinary reads and writes, WebSocket for urgent notifications, and both for an app with both workloads. Use HTTP for eth_call, balances, historical logs, and signed transaction broadcasts. After a broadcast times out, look up its transaction hash before sending again; a missing response does not mean the node missed the transaction.
Chainlist is an EVM network directory with chain IDs, RPC endpoints, and native currencies. When configuring a network, chainlist custom RPC changes which endpoint your wallet or Web3 tool targets; check for a working wss entry before planning subscriptions. Changing an https URL's prefix cannot create a WebSocket service.
For most interfaces, polling eth_getLogs over HTTP each block is enough. Keep the last fully processed block, request logs from the next block through the current head, and advance the checkpoint after processing. This also lets a reloaded page catch up. Viem offers http, webSocket, and fallback transports; its event watcher can poll or subscribe. Ethers likewise offers HTTP and WebSocket providers.
A subscription is a live notification stream; eth_getLogs queries a block range. After a socket drop, notifications during the gap do not replay, and the subscription ends with its connection. Receiving a new event after reconnect proves only that the new stream works. Events mined during the outage can otherwise vanish from your UI or bot state.
On reconnect, subscribe first, then read the current block height over HTTP. Query eth_getLogs from the block after your last fully processed block through that height, with the same address and topics. Merge those results with notifications received during the query. Deduplicate by block hash, transaction hash, and log index so overlap appears once. For a long outage, split the range into chunks the endpoint accepts, process them in order, and save the checkpoint after each chunk. If reorgs matter, rescan a short overlap or wait for confirmations, and remove logs from replaced blocks. Persist the checkpoint for process restarts.
Keep HTTP for user-initiated calls even when WebSocket signals a refresh. Use the socket for the feed needing immediate delivery, with backfill attached to that feed. Choose the transport per feature.
Related questions about RPC transport
Endpoint availability and failover can change the transport choice for a particular chain.
How to find a WebSocket RPC URL for a chain?
Find a wss endpoint for that chain and verify it accepts the subscription you need. An HTTP RPC says nothing about WebSocket availability.
Does WebSocket RPC cost more on providers?
Provider terms vary by endpoint, connection, request, and subscription. Compare the current rules for your expected connection count and event volume before cost affects the choice.
What is a fallback RPC transport?
A fallback transport tries another configured endpoint when a request fails. Viem's fallback transport does this for requests; a replacement WebSocket still needs resubscription and missed-log backfill.
Operational questions after choosing a transport
Connection health and browser behavior determine how much subscription handling your app needs.
How do I detect a dead WebSocket connection?
Watch close and error events, and use client keepalive or a heartbeat to catch silent stalls. On failure, reconnect, resubscribe, and backfill from the checkpoint.
Can browsers share one WebSocket across tabs?
Yes, through a SharedWorker or another coordination layer where browser support permits it. Otherwise, each tab generally opens its own connection. Share when fewer connections justify the extra tab lifecycle logic.
Do public RPCs rate-limit WebSocket subscriptions?
They can limit connections, subscriptions, or delivered messages. Check the endpoint's published limits and handle rejection or closure. Keep HTTP backfill for a critical feed.