#4215·quic-go

handshakeloss interop test fails for quic-go server because the server closes the connection after 5 seconds

Author: jaikiranCreated Dec 19, 2023Updated Sep 28, 2026
Labelsenhancementhelp wanted

When running the interop test "handshakeloss" against quic-go as the server, the test failed with:

Expected 50 handshakes. Got: 51

Looking at the logs, what seems to be happening here is that, the client is initiating a connection with an INITIAL packet which the quic-go server receives and creates a connection id for that incoming connect request:

2023/12/18 16:13:22 server Changing connection ID to 1a6717dc.
2023/12/18 16:13:22 Created qlog file: /logs/qlog/8d400180b4270a51bc38d805f45311bfc8.qlog
2023/12/18 16:13:22 Adding connection IDs 8d400180b4270a51bc38d805f45311bfc8 and 1a6717dc for a new connection.
2023/12/18 16:13:22 server <- Reading packet 2 (1200 bytes) for connection 8d400180b4270a51bc38d805f45311bfc8, Initial
2023/12/18 16:13:22 server 	Long Header{Type: Initial, DestConnectionID: 8d400180b4270a51bc38d805f45311bfc8, SrcConnectionID: a54057f7bea7cb8e0130976b51be1cbc1a986b61, Token: (empty), PacketNumber: 2, PacketNumberLen: 1, Length: 1153, Version: v1}
...

and responds to that INITIAL packet, with scid = 1a6717dc. Since this is "handshakeloss" test, the simulator drops this response packet from the server and the client never receives it. The client then retransmits that original INITIAL packet, but since this is handshakeloss test, the packet gets dropped and the server never receives that retransmission. This retransmission from the client happens a few more times and those packets get dropped. After 5 seconds (the default HandshakeIdleTimeout) the server closes this client initiated connection:

2023/12/18 16:13:27 Removing connection ID 8d400180b4270a51bc38d805f45311bfc8.
2023/12/18 16:13:27 Removing connection ID 16b1da65.
2023/12/18 16:13:27 Removing connection ID 1a6717dc.
2023/12/18 16:13:27 server accepting stream failed: timeout: no recent network activity
2023/12/18 16:13:27 server Connection 8d400180b4270a51bc38d805f45311bfc8 closed.

A second or two later, the client retransmits the original INITIAL packet, which this time makes it to the server, but since the quic-go server has already closed/aborted the previous connection request, it now creates a new connection id afresh for this incoming retransmitted INITIAL packet:

2023/12/18 16:13:28 server <- Received Initial packet.
2023/12/18 16:13:28 server Changing connection ID to 58750b92.
2023/12/18 16:13:28 Created qlog file: /logs/qlog/8d400180b4270a51bc38d805f45311bfc8.qlog
2023/12/18 16:13:28 Adding connection IDs 8d400180b4270a51bc38d805f45311bfc8 and 58750b92 for a new connection.
2023/12/18 16:13:28 server <- Reading packet 6 (1200 bytes) for connection 8d400180b4270a51bc38d805f45311bfc8, Initial
2023/12/18 16:13:28 server 	Long Header{Type: Initial, DestConnectionID: 8d400180b4270a51bc38d805f45311bfc8, SrcConnectionID: a54057f7bea7cb8e0130976b51be1cbc1a986b61, Token: (empty), PacketNumber: 6, PacketNumberLen: 1, Length: 1153, Version: v1}
...

and responds back with an INITIAL packet with the new connection id it just generated afresh scid = 58750b92

...
2023/12/18 16:13:28 server 	Long Header{Type: Initial, DestConnectionID: a54057f7bea7cb8e0130976b51be1cbc1a986b61, SrcConnectionID: 58750b92, Token: (empty), PacketNumber: 0, PacketNumberLen: 2, Length: 117, Version: v1}
2023/12/18 16:13:28 server 	-> &wire.AckFrame{LargestAcked: 6, LowestAcked: 6, DelayTime: 0s}

As a result, the captured packet trace will have 2 different "scid" values for the same connection that's being handshaked and thus the test fails with:

Expected 50 handshakes. Got: 51

Given that the "handshakeloss" test (intentionally) drops several packets during handshake, would it be better to not use the default HandshakeIdleTimeout (which is 5 seconds) and instead configure a higher value for it when specifically running this test? Something like this in the interop server's main.go:

diff
diff --git a/interop/server/main.go b/interop/server/main.go
index df704462..bd212530 100644
--- a/interop/server/main.go
+++ b/interop/server/main.go
@@ -7,6 +7,7 @@ import (
	"net"
	"net/http"
	"os"
+	"time"

	"github.com/quic-go/quic-go"
	"github.com/quic-go/quic-go/http3"
@@ -51,7 +52,14 @@ func main() {
		Certificates: []tls.Certificate{cert},
		KeyLogWriter: keyLog,
	}
-
+	// for handshakeloss test case, we need to increase the handshakidletimeout
+	// (which by default is 5 seconds), so that the server doesn't forget
+	// the connection after the default 5 seconds, during which time
+	// the handshake may not yet have been established (due to handshake loss)
+	if testcase == "multiconnect" {
+		quicConf.HandshakeIdleTimeout = 30 * time.Second // 30 seconds
+		fmt.Printf("Using HandshakeIdleTimeout: %s\n", quicConf.HandshakeIdleTimeout)
+	}
	switch testcase {
	case "versionnegotiation", "handshake", "retry", "transfer", "resumption", "multiconnect", "zerortt":
		err = runHTTP09Server(quicConf)

With this above change to increase the HandshakeIdleTimeout for this test, the handshakeloss test now passes.

Does this patch look reasonable and if it does, can this be applied to this upstream repo?