NWConnectionGroup no way to send/receive on QUIC stream with identifier `0`

Hello! I'm playing around with QUIC and Swift and using the Network framework. So far, the process has been really straightforward, but I noticed that I can't seem to get a handle on the stream with identifier 0.

If I use NWConnection directly, I only have access to the first stream, which has the stream ID 0. This not what I want since I wanna use multiple streams. Following the documentation, I started using NWMultiplexGroup and starting a NWConnectionGroup with it.

Everything works fine and I can get all streams that my backend service opens using NWMultiplexGroup's newConnectionHandler property. However, whenever backend sends a message on stream_id 0, none of my connections receive it. Looking around with

connection.metadata(definition: NWProtocolQUIC.definition) as? NWProtocolQUIC.Metadata

for each connection, I see that all streams are accounted for except stream 0. Then, using the NWConnectionGroup variant of the above

connectionGroup.metadata(definition: NWProtocolQUIC.definition) as? NWProtocolQUIC.Metadata

I see that the connection group itself has Stream ID 0. However, calling setReceiveHandler does nothing (it's never called, even when backend is sending messages) and when I attempt to send a message using NWConnectionGroup's -send method, a new stream is opened (instead of it being sent on stream ID 0).

How can one get a handle on NWConnection for stream ID 0?

I’m still coming up to speed on QUIC myself, so I spent some time digging into this. AFAICT this is working as designed. On the client side, you can create a QUIC connection in one of two ways:

  • As a connection, using NWConnection

  • As a connection group, using NWConnectionGroup

In both cases the object you create ‘owns’ stream ID 0. In the first case you can access it via the I/O methods on the connection. In the second case you can’t access it at all.

If there’s a specific reason you need to use a connection group and perform I/O on stream ID 0, I recommend that you file an enhancement request [1] explaining the real world impact of this limitation.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Or is it a bug report? That’s a tricky one (-: However, it doesn’t matter, it’ll go to the right folks either way.

NWConnectionGroup no way to send/receive on QUIC stream with identifier `0`
 
 
Q