Skip to content

Commit 7f96e7b

Browse files
committed
Introduce 1ms delay after opening SMUX stream to prevent header misinterpretation in WebSocket mode
1 parent e1d6bf6 commit 7f96e7b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/server/transport/wsmux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,9 @@ func (s *WsMuxTransport) handleSession(session *smux.Session, next chan struct{}
407407
return
408408
}
409409
// In my tests, sending the data frame immediately after opening the stream caused SMUX to misinterpret the header in WebSocket mode.
410-
// To prevent this issue, a short delay of 250 microsecond is introduced after opening the stream
410+
// To prevent this issue, a short delay of 1ms is introduced after opening the stream
411411
// before sending any data. This ensures proper header parsing by SMUX.
412-
time.Sleep(250 * time.Microsecond)
412+
time.Sleep(1 * time.Millisecond)
413413

414414
// Send the target port over the tunnel connection
415415
if err := utils.SendBinaryString(stream, incomingConn.remoteAddr); err != nil {

0 commit comments

Comments
 (0)