NSURLSessionStreamTask handling writes in wrong order when proxied
NSURLSessionStreamTask handling writes in wrong order when proxied
- Subject: NSURLSessionStreamTask handling writes in wrong order when proxied
- From: Jens Alfke <email@hidden>
- Date: Fri, 08 Jun 2018 09:51:17 -0700
My team’s analyzing a nasty issue where our network traffic sometimes gets
mangled when the client is behind a tunneling HTTP proxy.
* We call -[NSURLSession streamTaskWithHostName:port:] to open a TCP connection.
* We send data in WebSocket format, first using CFHTTPMessage to generate/parse
the handshake, then sending individual WebSocket messages. All data is written
via -[NSURLSessionStreamTask writeData:completionHandler:].
This works perfectly in general, and is used in our shipping product.
However, it fails when the (iOS) client is behind an HTTP proxy that supports
the CONNECT method (tunneling). CFNetwork automatically sends the CONNECT
request for us, so our code doesn’t have to deal with the proxy at all.
However, at some point the server starts rejecting our WebSocket messages as
invalid.
Using WireShark we’ve figured out that the WebSocket messages are sometimes
being sent to the (local) proxy in the wrong order. That is, the order in which
our data blobs are passed to -writeData:completionHandler: is not alway the
same order that the data blobs appear in the actual outgoing TCP stream.
Again, this only happens when using a proxy. And there is zero change to our
own code path when a proxy is present; we have no proxy-dependent code of our
own, we just rely on NSURLSession to handle it. So we’re forced to conclude
that something is going wrong inside CFNetwork.
Has anyone seen anything like this?
—Jens
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden