I'm seeing fully reproducible issues with URLSession on iOS 18.4 RC Simulator running from Xcode 16.3 RC. URLSession seems to get into a broken state after a second app run. The following sample succeeds in fetching the JSON on first app run but when the app is closed and ran again it fails with one of these errors:
Error: Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."
Error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out."
I'm wondering if this something related to my OS setup or is this due to internal URLSession changes in iOS 18.4. Already submitted as FB17006003.
Sample code attached below:
import SwiftUI
@main
struct NetworkIssue18_4App: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
@State private var message: String = ""
var body: some View {
VStack {
Text(message)
Button("Try Again") {
Task {
await fetch()
}
}
}
.task {
await fetch()
}
}
private func fetch() async {
message = "Loading..."
let url = URL(string: "https://poetrydb.org/title/Ozymandias/lines.json")!
let session = URLSession.shared
do {
let response = try await session.data(from: url)
print("Response: \(response)")
message = "Success, data length: \(response.0.count)"
} catch {
print("Error: \(error)")
message = "Error: \(error.localizedDescription)"
}
}
}
Networking
RSS for tagExplore the networking protocols and technologies used by the device to connect to Wi-Fi networks, Bluetooth devices, and cellular data services.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
The newly introduced enum value NEProviderStopReasonInternalError (macOS 15.1) is not documented (assuming being documented means having at least a sentence describing the enum value).
[Q] What kind of situation is the NEProviderStopReasonInternalError enum value supposed to describe?
An internal error that requires to try to restart the provider?
A fatal error that requires to reinstall macOS?
A fatal error that requires to purchase a new Mac?
Something less serious but with a human friendly description in the headers (I'm using Xcode 16.2) and online documentation.
Problem Description
When using iCloud Private Relay (Limit IP address tracking) on macOS Sonoma, I'm experiencing a DNS resolving issue when simultaneously connected via OpenVPN. The system activates iCloud Private Relay instead of using the DNS servers provided by the VPN connection, resulting in incorrect IP address resolution.
Specific issues:
When connected to my company VPN, the system ignores DNS servers set by the VPN connection
When attempting to ping internal servers in the corporate network, I receive public IP addresses instead of internal corporate IP addresses
These public IP addresses are not accessible from outside as some services are disabled for external access
Tools like nslookup and dig correctly resolve internal addresses, but ping and regular applications use incorrect (public) IP addresses
Access to local servers in the corporate network/subnet is problematic
Expected Behavior
I need the system to:
Use DNS servers provided by the VPN connection for accessing internal corporate resources when connected via VPN
Simultaneously maintain iCloud Private Relay protection for regular internet browsing while connected to VPN
Technical Details
Based on available information, the problem is likely caused by "iCloud Private Relay" inserting an additional DNS resolver that isn't visible through the scutil tool. Regular applications use macOS internal API for DNS resolving, while tools like dig and nslookup work differently.
According to Apple documentation, it should be possible to use custom DNS settings with iCloud Private Relay, but it doesn't seem to work properly with OpenVPN.
Temporary Solutions I've Tried
Some sources suggest:
Disabling iCloud Private Relay (I don't want to lose privacy protection)
Creating an /etc/resolver directory with configuration for specific domains
Manually adding static routes for specific IP addresses
None of these solutions provide the ideal combination of VPN DNS functionality and privacy protection.
Request for Solution
Please implement a solution that allows:
Prioritizing DNS servers provided by VPN connection for internal domains
Maintaining iCloud Private Relay protection for other communications
Ensuring consistent behavior of all applications during DNS resolving
Thank you for your help.
Topic:
App & System Services
SubTopic:
Networking
When I make a local network HTTP request, an error occurs. I'm sure I've granted wireless data permissions and local network permissions, and I'm connected to the correct Wi-Fi. This problem is intermittent, but once it happens, it will keep happening, and the only way to fix it is to restart the phone. Here is the error log:
sessionTaskFailed(error: Error Domain=NSURLErrorDomain Code=-1009 "似乎已断开与互联网的连接。" UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x30398a5b0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_NSURLErrorNWPathKey=unsatisfied (Local network prohibited), interface: en0[802.11], uses wifi, _kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask .<63>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask .<63>"
), NSLocalizedDescription=似乎已断开与互联网的连接。, NSErrorFailingURLStringKey=http://192.168.2.1:80/v1/parameters, NSErrorFailingURLKey=http://192.168.2.1:80/v1/parameters, _kCFStreamErrorDomainKey=1})
My app sent a network request to the backend. The backend returns a 200, but the front end received a -1001 or -1005 NSURLError. Any clue why this could be happening?
Is it possible using the network framework to retrieve the list of certificates presented by the host alone, and not the reconstructed chain assembled by the system?
For example, in OpenSSL one can call SSL_get_peer_cert_chain which will return exactly this - a list of the certificates presented by the server. This is useful for when you may want to manually reconstruct the chain, or if the server is misconfigured (for example, is missing an intermediate cert).
Is something like this possible with the network framework?
If I connect to a host that I know only returns 1 certificate, the trust ref already has the reconstructed chain by the time my code is called:
sec_protocol_options_set_verify_block(tlsOptions.securityProtocolOptions, { metadata, trustRef, verifyComplete in
let trust = sec_trust_copy_ref(trustRef).takeRetainedValue()
let numberOfCertificates = SecTrustGetCertificateCount(trust) // Returns 3 even though the server only sent 1
Could anyone teach me how to ask iOS 18 to have a prompt during set-up process of a new APP if user accidentally turns off Local Network ?
When I use NSURLSessionTaskTransactionMetrics property domainLookupStartDate and domainLookupEndDate to calculate the duration of DNS, sometimes I get 4294893875545978 or -4294893875545978 return
method like this
[NSNumber numberWithLongLong:[taskMetrics.domainLookupEndDate timeIntervalSinceDate:taskMetrics.domainLookupStartDate?]*1000000000]
The hexadecimal value of 4294893875545978 is 0xF3F3F3F3F3F3A.
Is 4294893875545978 a special value?
Topic:
App & System Services
SubTopic:
Networking
Could anyone tell me how to detect status of Local Network for iOS 18+ systems ?
Hi everyone, I developed an Android version of a VPN app built with Flutter using OpenVPN, and it works perfectly on Android. However, when porting it to iOS, I’ve encountered an issue: the app connects successfully but then automatically disconnects when tested via TestFlight. We’ve already added all the necessary network extensions. Despite this, we decided to submit the app to the App Store. It’s been five days now, and the app is still 'Waiting for Review.' Could anyone share their experience deploying and working on an iOS version of a VPN app? I’d really appreciate your insights!
It doesn’t seem like there’s any high level, first-party documentation on how to use what is the recommended API for executing networking logic that you otherwise wouldn’t use URLSession for; which is a lot of things.
There’s a sample app, and docs on how to
choose the right network API in general, but apparently no high level API docs for Network.framework itself. Am I missing something? How do people learn to use this? Know which classes to use? Know the various ways it can be configured?
We have developed a DNS filter based on NEDNSProxyProvider. It works great for a minute, then it stops responding. Our logs indicate that during the outage our extension gets DNS requests and formulates DNS responses that it hands back to the OS, but from outside of our code it is as though our extension is not responding.
Dear Apple Team,
I am facing an issue with UDP networking in my watchOS app for duplex audio streaming using NWConnection. I have already added the necessary capabilities, including background mode for audio, to ensure smooth operation.
Issue Details:
The UDP connection works fine on the simulator since it uses macOS networking and allows low-level access.
However, on a real Apple Watch (running watchOS 10), the connection remains in a "waiting" state and fails with Error 50.
I am aware of Technical Note TN3135 regarding low-level networking on watchOS, but even after following these guidelines, the issue persists.
Questions:
Does watchOS impose additional restrictions on UDP networking compared to iOS/macOS?
Are there any specific entitlements or configurations required to allow UDP connections on a real Apple Watch?
Is there a workaround or debugging method to get more insights into why the connection fails?
I would appreciate any guidance or recommendations on resolving this issue.
Apology for repost. I needed to fix the tags for original thread.
https://developer.apple.com/forums/thread/777159
On iOS 18.3, I noted that partition "HTTPCookiePropertyKey: StoragePartition" is not observed to be set for cookies returned from the wkwebview cookie store.
Now on 18.4 beta 4 we are now seeing those same cookies are populated with a partition property. Is there documentation for this change? Is it intended to be suddenly populated in 18.4?
Now that partition property is set, HTTPCookieStorage.shared.cookies(for: serverUri) doesn't seem to return the expected cookies correctly. For context, we are using the cookies extracted from wkwebview, setting them in HTTPCookieStorage.shared and using URLSession to make network calls outside the webivew. Works fine once I forcefully set partition on the cookie to nil.
More details on what the cookie looks like here: https://feedbackassistant.apple.com/feedback/16906526
Hopefully this is on your radar?
Just bought a macbook pro m4, im trying to run an api on port 5000, disabled airplay receiver, checked processes, ghost ones, hidden ones, and stuck ones. I didn't find a thing using the port, but i still get port in use.
Topic:
App & System Services
SubTopic:
Networking
On iOS 18.3, I noted that partition "HTTPCookiePropertyKey: StoragePartition" is not observed to be set for cookies returned from the wkwebview cookie store.
Now on 18.4 beta 4 we are now seeing those same cookies are populated with a partition property. Is there documentation for this change? Is it intended to be suddenly populated in 18.4?
Now that partition property is set, HTTPCookieStorage.shared.cookies(for: serverUri) doesn't seem to return the expected cookies correctly. For context, we are using the cookies extracted from wkwebview, setting them in HTTPCookieStorage.shared and using URLSession to make network calls outside the webivew. Works fine once I forcefully set partition on the cookie to nil.
More details on what the cookie looks like here:
https://feedbackassistant.apple.com/feedback/16906526
Hopefully this is on your radar?
Hello. I would like to develop an application that sends SSH commands via my phone to the server. I know that applications of this type exist, but they are not suitable for my use as a blind person who uses a screen reader. I hope you can help me find libraries that will assist me in development, or ready-made, open-source projects that I can develop and modify if necessary. Thank you in advance.
Topic:
App & System Services
SubTopic:
Networking
When I used the iPhone 11 to scan the wifi connection, the system reported an error,
‘’’
let config = NEHotspotConfiguration(ssid: name, passphrase: passwd, isWEP: false)
let manager = NEHotspotConfigurationManager()
manager.apply(config) { error in
}
’’’
NEHotspotConfigurationErrorDomain Code=8 “internal error.” , the only thins that fixes this issue it restarting the iPhone.
What is the reason for this and how to solve it?
Reference link:
https://developer.apple.com/forums/thread/111638
https://cloud.tencent.com/developer/ask/sof/114654981
I would like to develop a macOS app that would automatically switch Network Locations based on certain criteria. I want to publish this on the Mac App Store, but I'm unsure if this functionality is permitted.
I've searched through the App Store Review Guidelines and documentation on NetworkExtension and SystemConfiguration frameworks, but I haven't found clear information on whether:
Programmatically changing Network Locations is allowed in sandboxed App Store apps
What specific entitlements would be required
If there are any API-approved ways to do this without shell commands
I'd like to avoid investing significant development time if this type of functionality would ultimately be rejected. As a relatively new Apple platform developer, any guidance on:
The appropriate frameworks/APIs to use
Required entitlements
Whether this functionality is even permitted for App Store distribution
would be incredibly helpful.
Thank you in advance for any insights!
Topic:
App & System Services
SubTopic:
Networking
Tags:
Network Extension
System Configuration
CFNetwork
Hey!
We are investigating a problem pf rules being ignored by some processes. Despite blocking all traffic, some outgoing unicast packets can be seen in tcpdump. Issue is present in MacOS 15.0.0 - 15.3.1 (Newest at the time of writing). I tested MacOS 14.7.4 and pf rules there behaved as expected. Steps to reproduce the issue:
$ cat pf.conf
block all
$ sudo pfctl -e -F all -f ./pf.conf
Password:
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset added by the system at startup.
See /etc/pf.conf for further details.
No ALTQ support in kernel
ALTQ related functions disabled
rules cleared
nat cleared
dummynet cleared
0 tables deleted.
196 states cleared
source tracking entries cleared
pf: statistics cleared
pf: interface flags reset
pfctl: pf already enabled
After executing these commands MacOS 14 will block all outgoing unicast traffic, and on MacOS 15 data can be sent to arbitrary addresses:
$ ifconfig en0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=6460<TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
ether b6:5e:a5:c5:1e:db
inet6 fe80::1090:9c8:4325:329a%en0 prefixlen 64 secured scopeid 0xe
inet 192.168.50.144 netmask 0xffffff00 broadcast 192.168.50.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
$ sudo tcpdump -k A -i any -n src 192.168.50.144
tcpdump: data link type PKTAP
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type PKTAP (Apple DLT_PKTAP), snapshot length 524288 bytes
12:05:12.673472 (en0, proc com.apple.geod:1286:, svc BE, out, ch, flowid 0x0, ttag 0x0, dlt 0x1, cmpgc 0x0) IP 192.168.50.144.52012 > 17.253.15.196.443: Flags [P.], seq 1888882378:1888882402, ack 3554898220, win 2048, options [nop,nop,TS val 2752050055 ecr 1291585385], length 24
12:05:13.793937 (en0, proc com.apple.WebKit:974:, eproc Safari:804:, svc BE, out, ch, flowid 0x0, ttag 0x0, dlt 0x1, cmpgc 0x0) IP 192.168.50.144.52024 > 3.65.102.105.443: Flags [P.], seq 2011312019:2011312073, ack 673002582, win 2048, options [nop,nop,TS val 777228223 ecr 484269939], length 54
Was there any change in the way pfctl is used or is this a bug? This issue affects negatively privacy features of our product.
Topic:
App & System Services
SubTopic:
Networking