mirror of
https://github.com/dalbodeule/hop-gate.git
synced 2025-12-12 06:40:11 +09:00
Fix client handling of unexpected stream frames at top level
- Add handling for StreamData and StreamClose at top level in client StartLoop - Log warning and continue instead of crashing on unexpected frames - Fixes "unsupported envelope type stream_close" error when frames arrive out of order Co-authored-by: dalbodeule <11470513+dalbodeule@users.noreply.github.com>
This commit is contained in:
@@ -238,6 +238,30 @@ func (p *ClientProxy) StartLoop(ctx context.Context, sess dtls.Session) error {
|
|||||||
"seq": seq,
|
"seq": seq,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
case protocol.MessageTypeStreamData:
|
||||||
|
// StreamData received at top level (not expected, should be consumed by handleStreamRequest)
|
||||||
|
// This can happen if frames arrive out of order or if there's a protocol mismatch
|
||||||
|
log.Warn("received unexpected stream_data at top level, ignoring", logging.Fields{
|
||||||
|
"stream_id": func() string {
|
||||||
|
if env.StreamData != nil {
|
||||||
|
return string(env.StreamData.ID)
|
||||||
|
}
|
||||||
|
return "unknown"
|
||||||
|
}(),
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
case protocol.MessageTypeStreamClose:
|
||||||
|
// StreamClose received at top level (not expected, should be consumed by handleStreamRequest)
|
||||||
|
// This can happen if frames arrive out of order or if there's a protocol mismatch
|
||||||
|
log.Warn("received unexpected stream_close at top level, ignoring", logging.Fields{
|
||||||
|
"stream_id": func() string {
|
||||||
|
if env.StreamClose != nil {
|
||||||
|
return string(env.StreamClose.ID)
|
||||||
|
}
|
||||||
|
return "unknown"
|
||||||
|
}(),
|
||||||
|
})
|
||||||
|
continue
|
||||||
default:
|
default:
|
||||||
log.Error("received unsupported envelope type from server", logging.Fields{
|
log.Error("received unsupported envelope type from server", logging.Fields{
|
||||||
"type": env.Type,
|
"type": env.Type,
|
||||||
|
|||||||
Reference in New Issue
Block a user