quinn-rs / quinn

Async-friendly QUIC implementation in Rust
Apache License 2.0
3.76k stars 380 forks source link

long running bi stream #1866

Closed szguoxz closed 4 months ago

szguoxz commented 4 months ago

Is it a good practice to open_bi, and keep it open forever, i.e., days, months? is the connection/stream stable enough to be open, even for years?

djc commented 4 months ago

If you need framing we generally recommend using one stream per frame.

szguoxz commented 4 months ago

I am wondering why? What is the potential problem? So you mean long running stream is OK for non framed use case?

Ralith commented 4 months ago

You can keep streams open for as little or as much time as you like. Are you having trouble with that?

szguoxz commented 4 months ago

I am just wondering why you suggest one frame per stream. I am currently using length delimited frame. and my connection got stuck from time to time. (sometimes in a day or two days, some times in a few minutes if I am lucky). I can't be sure this is the problem, as I still don't know how to reproduce it. So I don't want to blame the stream yet. I just want to clarify two things:

For cost wise, theoretically, which one is cheaper? length delimited or one frame per stream? as length delimited, every frame I need to two bytes to the payload. What is the cost for one stream per frame? Let's forget about MTU split ... etc. What is the addition costs we need to pay to transfer a stream? After all, you need a internal frame to implement unistream.read_to_end.

I know they are almost the same cost, buy theoretically, which one is cheaper? Why do you suggest the later?

Ralith commented 4 months ago

They are both very cheap, but have different semantics. The question has nothing to do with "cheaper". A single stream will always deliver data in order; separate streams allow for out-of-order processing if you want it, and can save you the trouble of implementing your own framing. You should use whichever approach makes more sense for your application.

I am currently using length delimited frame. and my connection got stuck from time to time

Is this about the same problem you raised in #1867? Please only open one issue to describe a specific problem. It is difficult to track a discussion spread across multiple threads.