Skip to content

Conversation

0xsimulacra
Copy link
Contributor

Hello,

Following on issue 81, this PR adds Round Trip Time (RTT) from the node to the upstream flahblocks proxy as debug message.

If it is of interest, the debug message can be replaced by a stored metric instead.

P.S: I'm relatively new to Rust, and only have past extensive experience in Python and Go.

@haardikk21
Copy link
Contributor

how does this work? does tokio-tungstenite echo back the same data from the PING in the PONG? is this documented somewhere? because otherwise without changes to the websocket proxy how is it sending you back the timestamp of the ping?

@0xsimulacra
Copy link
Contributor Author

This behavior is defined by the WebSocket protocol (RFC 6455):

A Pong frame sent in response to a Ping frame must have identical “Application data” as found in the message body of the Ping frame being replied to.

See: https://www.rfc-editor.org/rfc/rfc6455#section-5.5.3

I’ve been measuring RTT using this Ping/Pong method when connecting to Web3 providers and recently added it to my Reth node for flashblocks—the results have been consistent.

@0xsimulacra
Copy link
Contributor Author

0xsimulacra commented Oct 3, 2025

It also looks like tokio-tungstenite follows the WebSocket specs via tungstenite:

  1. The write method docs state that Pong responses are queued automatically as soon as a Ping is received:

    upon receiving ping messages tungstenite queues pong replies automatically.

  2. Line 651 shows that read_message_frame queues a Pong for the Ping opcode using data.clone() from the received Ping.

  3. This issue indicates the behavior is implemented correctly, and tungstenite passes the Autobahn testsuite for WebSocket client and server implementations.

@haardikk21 haardikk21 self-requested a review October 6, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants