Notification Extension - Network request with local proxy set fails with "Network is down" error on T-Mobile Network

I get below error on iPhones using T-Mobile network when mobile data is enabled.

iPhone using other service providers like Verizon does not encounter this issue. No issue is observed when connecting to WiFi as well.


handleStreamError::UnderlyingError.domain=NSPOSIXErrorDomain, error.code=50, error.description=Error Domain=NSPOSIXErrorDomain Code=50 Network is down" UserInfo={_kCFStreamErrorCodeKey=50 _kCFStreamErrorDomainKey=1}"


We setup a SOCKS proxy and make network requests by setting SOCKS Proxy as below,


CFReadStreamSetProperty((CFReadStreamRef)readStream, kCFStreamPropertySOCKSProxy, proxyToUse);


Callback set to CFReadStreamSetClient() receives below error on CFReadStreamOpen(),


Inside handleNetworkEvent::kCFStreamEventErrorOccurred calling handleStreamError

handleStreamError::UnderlyingError.domain=NSPOSIXErrorDomain, error.code=50, error.description=Error Domain=NSPOSIXErrorDomain Code=50 Network is down" UserInfo={_kCFStreamErrorCodeKey=50 _kCFStreamErrorDomainKey=1}"


Above request is made from Notification Extension and it fails. We make a similar request from App side and it works without any issue.


Could someone please help me understand what might be going on here or suggest how to debug this issue further ?


Devices: iPhone XR, iOS 12.x, 13.x

Replies

Does your setup handle IPv6-only networks properly? That’s the most common cause of problems that only show up on T-Mobile (I’m presuming that this is in the US, where T-Mobile provides Apple devices with an IPv6-only DNS64/NAT64 network).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

ps DTS is closed 21 Dec through 1 Jan.

Sorry for the delayed response and thanks for the pointers.


We were creating SOCKS proxy socket by passing only port number, which internally uses in6addr_any address for IPV6 socket. This address doesn't work for accepting connections for IPv6 client, whereas counterpart INADDR_ANY works fine for IPv4


We need to use loopback/localhost as interface name while creating SOCKS proxy socket. This internally creates socket with in6addr_loopback address for IPv6 socket.