I’ve a category that makes use of a “sure pair” of Basis streams, created with the getBoundStreams(withBufferSize:inputStream:outputStream:)
technique. The InputStream
of the sure pair is used to stream request physique knowledge right into a URLRequest
by way of the httpBodyStream
property, whereas I feed knowledge in by way of the pair’s OutputStream
.
After I create one sure pair of Basis streams & use it for a URLRequest
, it really works superb – the OutputStream
informs its delegate when it has house accessible, it accepts knowledge by way of its write(_:maxLength:)
perform, and this continues till all the info has been accepted; then I shut the OutputStream
, the InputStream
closes as nicely, and my URLRequest
has been despatched with the streamed request physique.
However when I attempt to create two pairs or extra of sure streams at a time and try to make use of them concurrently, just one pair works. I’ve tried from one to 10 sure stream pairs at a time, and in each case, one pair succeeds and all the opposite pairs fail as follows.
On the failed stream pairs, the next occasions happen:
- I set my
StreamDelegate
on theOutputStream
, then open it withopen()
. - The
OutputStream
opens, and the.hasSpaceAvailable
occasion is delivered to its delegate. - I attempt to write to the
OutputStream
withwrite(_:maxLength:)
, however the return worth is-1
indicating an error occurred. - I question the
OutputStream
‘sstreamStatus
and the standing is5
(.atEnd
). - I question the
OutputStream
‘sstreamError
and it’snil
.
I’ve tried configuring my OutputStream
s to ship occasions on each a RunLoop
and on a GCD queue, and it fails the identical both approach. I all the time entry the stream on its configured RunLoop or GCD queue, by no means from some other context.
I see completely nothing within the Basis Stream
docs about limiting the variety of pairs of sure streams or interactions between coexistent pairs of sure streams.
So what is going on on right here? Anybody seen the identical with sure pairs of Basis streams? Am I lacking one thing in my config wanted to make this work, or lacking one thing within the docs that claims a number of simultaneous stream pairs isn’t supported? Thanks!