I want to know why the "NSURLErrorDomain Code=-1000" error occurs and how to fix it?

PLATFORM AND VERSION: iOS
Development environment: Xcode 15.4, macOS 14.4
PROBLEM iOS VERSION: iOS 17.2.1 ~ 18.1.1
DEVELOPMENT LANGUAGE: Object-C

Case-ID: 10969723

(Due to privacy concerns, I have hidden part of the URL and included the complete plain text in the email demo project with Case-ID: 10969723)

After our game was launched in Japan, a small number of Japanese users reported that they were unable to enter the game. After our investigation, we confirmed that the request under the yfy-api-oversea.xxxxxxxxxxxxxx.com domain name failed.

iOS NSURLSession API returns the following error:
Error Domain=NSURLErrorDomain Code=-1000 "無効なURL" UserInfo={_kCFStreamErrorCodeKey=22, NSUnderlyingError=0x3019e8030 {Error Domain=kCFErrorDomainCFNetwork Code=-1000 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], ipv4, ipv6, dns, proxy, uses wifi, _kCFStreamErrorCodeKey=22, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <E15BF3AD-CBB0-4CE2-9C4E-34BF05DDC297>.<7>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <E15BF3AD-CBB0-4CE2-9C4E-34BF05DDC297>.<7>" ), NSLocalizedDescription=無効なURL, NSErrorFailingURLStringKey=https://yfy-api-oversea.xxxxxxxxxxxxxx.com/init/info?channel_code=jpxxxxxxxxxxxxxxios&timestamp=1735012505&sign=1617e4cf88b58df2aa90a6b3985a8ac2&game_code=XXXXX, NSErrorFailingURLKey=https://yfy-api-oversea.xxxxxxxxxxxxxx.com/init/info?channel_code=jpxxxxxxxxxxxxxxios&timestamp=1735012505&sign=1617e4cf88b58df2aa90a6b3985a8ac2&game_code=XXXXX, _kCFStreamErrorDomainKey=1}。

We have tried various methods but cannot reproduce this error (Code=-1000).

I can provide the following clues:
1、We have checked the server and confirmed that the request did not reach the server, but was intercepted by the iOS client and was not sent.
2、This problem does not seem to have much to do with the iOS system version. The system versions where the problem occurred are widely distributed: 17.2.1、17.7.1、17.5.1、17.6.1、17.7、18.0.1、18.1、18.1.1 e.g.
3、This problem seems to have nothing to do with the device model. The following models have experienced problems: iPhone16、iPhone 16 Pro、iPhone 14、iPhone 14 Plus、iPhone 14 Pro Max、iPhone 13、iPhone11 e.g.
4、By tracking the logs, some users who encountered the problem later recovered and the problem did not occur again(The user IP and iOS system restored by yourself have not changed). However, this problem persists for some users. Even if the iOS system is upgraded to the latest version, there are still problems.
5、The following two IPs are the IPs of users who encountered this problem (1.73.13.210, 153.252.131.136). But this problem seems to have nothing to do with IP. For some users who restored themselves, their IPs did not change, but the problem no longer occurred.
6、This problem seems to only occur in Japan. Mainland China, Taiwan, and Hong Kong have never encountered this situation.
7、It doesn't seem to have anything to do with GET requests. Another login request (https://yfy-api-oversea.xxxxxxxxxxxxxx.com/login/c/place) uses a POST request and will also encounter this error.
8、I wonder if it has something to do with the two symbol "-" in the domain name?

I checked Apple documentation and searched online, but couldn't find any more information. This problem cannot be reproduced either. Only technical requests can be initiated.

I provided a demo project (see email for Case-ID: 10969723)

Thanks.

Error -1000 is NSURLErrorBadURL (or, equivalently, kCFURLErrorBadURL). It’s very rare. I can see two potential causes for it:

  • Custom URL protocols

  • Proxies

Honestly, I suspect it’s the latter, but let’s start by ruling out the first. Does your app subclass URLProtocol (Swift) or NSURLProtocol (Objective-C)?

Share and Enjoy

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

@DTS Engineer

I'm not using a custom URL protocol or even a third-party networking library. I just used the iOS native network NSURLSession as shown in the Demo I provided.

[[NSURLSession sharedSession] dataTaskWithRequest:aRequest completionHandler:]

There is one thing that has not been mentioned before. Network requests are sent from the dynamic library (Framework) we developed ourselves, not from the main App.

I'm not using a custom URL protocol

Thanks for confirming that.

I strongly suspect that this is related to your user’s networking environment rather than your code. You wrote:

Network requests are sent from the dynamic library (Framework) we developed ourselves, not from the main App.

That’s almost certainly not a concern. A standard URLSession [1] runs within your process and it treats all code within your process the same.

Are you in contact with one or more users who are having this problem? If so, my suggestion is that you ‘productise’ your demo app, send them a copy, and have them run it. If that has the same problem then you know it’s nothing to do with your code but rather it’s something on their system. OTOH, if the demo app works, there’s something more subtle in play.

The other thing you could have them do is capture a sysdiagnose log immediately after triggering the problem and send it to you. The networking stack — both CFNetwork and Network framework — log a lot of information to the system log, and that might give you a clue as to what’s going wrong.

For more information about the system log, see Your Friend the System Log. For some hints and how to use sysdiagnose logs for this sort of thing, see Using a Sysdiagnose Log to Debug a Hard-to-Reproduce Problem.

Share and Enjoy

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

[1] As opposed to a background session. The story with background sessions is more nuanced.

I want to know why the "NSURLErrorDomain Code=-1000" error occurs and how to fix it?
 
 
Q