Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To test whether a realtime auction bidder is present, check more than whether its WebRTC connection is connected. Transport can be working while the bidder is unauthenticated, unsubscribed, stale, or no longer participating. A useful Go contract test covers five signals—signaling, ICE, aggregate peer connection state, ICE candidate flow, and application liveness—and defines what the auction service should do for each.

These five signals are an engineering test frame, not a presence model defined by WebRTC. Pion, a pure Go implementation of the WebRTC API, exposes state callbacks and accessors that help test the transport and signaling parts; your application must define participation and liveness rules.

How do I test WebRTC connection state in Go?

Use Pion’s Go WebRTC API to observe the state transitions your signaling protocol expects, then test application-level participation separately. The Pion v4 API documents the callbacks and accessors for signaling, ICE, aggregate peer connection state, and candidate gathering: Pion v4 API documentation.

The Pion repository identifies github.com/pion/webrtc/v4 as its current major package path and describes Pion as “A pure Go implementation of the WebRTC API.” Pin the v4 dependency used by your service and confirm the version when you update it: Pion WebRTC repository.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A contract test should assert behavior your application relies on, not one universal sequence for every WebRTC session. For example, the expected signaling transitions depend on whether your auction service exchanges offers, answers, and renegotiation messages in a particular order. The same principle applies to trickle ICE: verify the candidate-delivery behavior your protocol actually requires.

Which five presence signals should a bidder contract test cover?

Signal Layer observed What to test What it says about bidder presence
Signaling state Offer/answer signaling Expected state transitions for your exchange and renegotiation contract Shows signaling lifecycle progress, not that the bidder is authenticated or participating
ICE connection state ICE transport Relevant states, failures, closure, and recovery behavior Shows transport conditions, not application responsiveness or auction subscription
Aggregate peer connection state Combined WebRTC connection State-change handling, errors, and close behavior Summarizes WebRTC connection state; it is not application health
ICE gathering and candidate flow ICE setup and signaling protocol Candidate collection, conveyance, and end-of-gathering behavior Shows whether connectivity information is being exchanged as designed
Application liveness Auction application Heartbeat or participation acknowledgment freshness and timeout handling Provides the direct evidence your application defines for current participation

1. Signaling state: test the offer/answer contract

Pion provides OnSignalingStateChange and SignalingState() to observe signaling state. Assert the transitions your service expects as it creates and exchanges session descriptions. Avoid hard-coding a generic sequence without considering your own offer/answer roles and renegotiation flow.

Signaling state can establish where a peer connection is in its negotiation lifecycle. It cannot establish that a bidder has authenticated, subscribed to the auction, or remains responsive after negotiation.

2. ICE connection state: test transport changes and recovery

Pion’s ICE states describe conditions of the ICE transport. Cover the states relevant to your contract: new, checking, connected, completed, disconnected, failed, and closed. Pion documents these transport meanings in its ICE state definitions: Pion ICE connection state source.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not treat connected or completed as proof of auction participation. A peer can have ICE connectivity while its application session is no longer useful to the auction.

Also distinguish a temporary disconnected condition from a definitive failure. Pion’s example notes that disconnection can be useful for faster timeout detection while recovery may still occur: Pion play-from-disk example. The auction service should define its own grace-period semantics—for example, whether it retains a bidder provisionally, marks it suspect, or evicts it after an application-defined deadline.

3. Aggregate peer connection state: handle combined WebRTC health

Pion exposes OnConnectionStateChange and ConnectionState() for aggregate peer connection state. Test the transitions your service uses for connection handling, including its error and close paths. In Pion’s implementation, aggregate peer connection state is computed from ICE and DTLS transport states: Pion peerconnection.go.

This aggregate view is useful for deciding whether to maintain or tear down a WebRTC connection. It still describes WebRTC state, not whether the bidder application has a valid session or is consuming the current auction.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. ICE gathering and candidate flow: test the signaling boundary

Candidate handling is part of the application contract because the peers need to exchange connectivity information through whatever signaling protocol the auction service uses. Pion documents that gathering begins after setting a local or remote description and that its candidate callback receives nil when gathering finishes: Pion v4 API documentation.

Write tests for the protocol your application chose:

  • Trickle ICE: verify that candidates are forwarded as they arrive and associated with the correct session.
  • Wait for gathering: verify that the offer or answer is sent only after candidate gathering has finished, according to your signaling design.
  • Completion: verify that your code handles the end-of-gathering notification rather than waiting indefinitely for another candidate.

Whether to trickle candidates or wait for completion is a design choice. The contract test should pin the behavior your implementation uses, not assume one approach is required by Pion.

5. Application liveness: verify participation directly

Define an application-level message that means something operationally useful: for example, a heartbeat, an auction-subscription acknowledgment, or another message that demonstrates the bidder session is active. Test that the service records freshness and handles messages that arrive late or stop arriving.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

No universal heartbeat cadence or bidder timeout is established for an unspecified auction product. Set those values from the product’s service-level objective and auction rules. Tests should use the configured product policy rather than inventing a threshold from WebRTC state.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How can I tell if a WebRTC peer is still connected?

Use WebRTC state to answer whether the relevant signaling and transport layers are functioning, and application messages to answer whether the bidder is still participating. These are related checks, not interchangeable proofs. A connected peer may have stale application liveness; a brief ICE disconnection may recover before the auction’s business rules require eviction.

Make the service action explicit for each tested condition. A practical policy maps observations to actions such as retain, suspect, evict, or reconnect. The action is an auction product decision; Pion supplies state signals, not bidder-presence policy.

How do I detect a disconnected bidder?

Test the transition from a healthy session through interruption, recovery or timeout, and final cleanup. In particular, a contract should specify how transport disconnection interacts with application liveness: a recovered ICE connection may restore transport, while a missed subscription acknowledgment or expired heartbeat may still make the bidder ineligible under your auction rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Establish the session: verify the expected signaling exchange, candidate flow, and transport connection.
  2. Interrupt or stop application messages: verify that the service notices stale participation independently of WebRTC connectivity.
  3. Exercise transient recovery: verify the configured behavior when ICE reports disconnected and later recovers.
  4. Exercise terminal handling: verify what the service does on failed, closed, or an application liveness timeout, as applicable to the contract.
  5. Check cleanup and eligibility: verify the bidder’s auction-session status and any reconnect path so a stale session is not silently treated as an active participant.

Keep the assertions tied to observable contracts: callbacks and state accessors for WebRTC conditions, and your own messages and deadlines for application presence. Pion also exposes data-channel and track events, which can be tested when they are part of your session’s behavior; they do not replace an application-defined participation rule.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.