http
http copied to clipboard
[ios] [CupertinoClient] http connection issue: nw_path_necp_check_for_updates Failed to copy updated result (22)
We are facing http connection issue when using CupertinoClient.
CC: @brianquinlan would you be so kind as to take a quick look at this? Just noticed you might know why this occurs.
To reproduce:
- create a CupertinoClient as per code below
- make http connection to whatever web api
- http client will stall and console will print this error:
console nw_path_necp_check_for_updates Failed to copy updated result (22)
Note: Issue occurs frequently if device is connected to Internet via a VPN.
It seems this issue occurred also in the past, maybe a regression? https://github.com/flutter/flutter/issues/111940
Code sample
Code is simple, as per instructions from http package Readme. Use below ConnectionService.client to call whatever rest api on iOS. Note: We needed to use CupertinoClient coz connectivity with standard dart client was pretty unstable.
class ConnectionService {
static const String _debugPrefix = 'ConnectionService:';
static final config = URLSessionConfiguration.ephemeralSessionConfiguration()
..allowsCellularAccess = false
..allowsConstrainedNetworkAccess = false
..allowsExpensiveNetworkAccess = false;
// Initialize client. It will be CupertinoClient on iOS and IOClient on android
static dynamic client = (Platform.isIOS) ? CupertinoClient.fromSessionConfiguration(config)
: IOClient();
Logs
Error from console is: console nw_path_necp_check_for_updates Failed to copy updated result (22)
Note: We have this issue with both cupertino_http: 1.0.0 and 0.1.2
Flutter doctor
[✓] Flutter (Channel master, 3.12.0-7.0.pre.22, on macOS 12.6.5 21G531 darwin-arm64, locale en-IT)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
✗ cmdline-tools component is missing
Run path/to/sdkmanager --install "cmdline-tools;latest"
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run flutter doctor --android-licenses
to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] Connected device (3 available)
[✓] Network resources
Hi @delfme ,
I'm not sure why this happens?
Does this happen while your app is in the foreground, background or both?
Do you have the com.apple.security.network.client
entitlement set?
Hi @brianquinlan thx for the kind support!
It surely happens while app is in foreground. Couldn't check what happens with app in background.
I added com.apple.security.network.client
to entitlement.
Couldn't find it from capabilities panel (is that a config. issue?), so added it manually to Runner.entitlements files (pic below). Is that the same?
Will test things and revert.
Actually, the entitlement is not relevant for your configuration.
There isn't really much for me to use to diagnose the problem here. Do you see an error if you use IOClient
?
Issue with IOClient
was slow connection time on iOS and being a bit unstable.
That brought us to turn to CupertinoClient
.
It would be great if CupertinoClient
could be tested more under VPN and different network condition.
The feeling is that there is a minor bug that is somehow triggered by these conditions.
Since CupertinoClient
relies on Apple APIs for network transport, any bugs related to network conditions would most likely be related to those APIs.
Regarding https://github.com/dart-lang/http/issues/972#issuecomment-1622546678 - I meant have you tested the scenario that demonstrates this bug using IOClient
?
I am having the same issue. No http request is failing properly speaking, and I also see that keep-alive is working as expected.
Still, I can see there is an important slowdown when running my application, at least in debug mode (USB debugging).
Not sure it is related but - more worrying perhaps - I am sometimes seeing lots (and I say lots) of
[Client called nw_connection_copy_protocol_metadata_internal on unconnected nw_connection]
errors, as reported in the comments here:
https://stackoverflow.com/questions/76397964/client-called-nw-connection-copy-protocol-metadata-internal-on-unconnected-nw-co
My setup is described in the comments in the link above. I am using http 1.1.0
.
I can't recall what triggered this new behavior.
Since
CupertinoClient
relies on Apple APIs for network transport, any bugs related to network conditions would most likely be related to those APIs.Regarding #972 (comment) - I meant have you tested the scenario that demonstrates this bug using
IOClient
?
@brianquinlan Yes, there is the bug when simply using IOClient
on iOS. I can reproduce the bug on iOS 16.6 with the following setup:
- connecting to a LAN machine through plain http.
- the HTTP server is hosted by a WAMP server on a Windows 11 machine that only has IPv4 enabled
- the iOS device has both an IPv4 and IPv6 address.
To reproduce the problem, issue eg. 100 http requests with, say, a 1-second interval. From times to times, you will see the issue.