NETWORK: NWPathMonitor non-functional on AppleWatch

I’m trying to trace down connectivity issue with a Watch App; Preflighting the app has Bluetooth and WIFI Access.
 
I have code that works well on iOS, but the NWPathMonitor always return that there is not Network connection because “unsatisfied (Path was denied by NECP policy), interface: ipsec0, ipv4”

What is NECP? What is NECP Policy? Why does this work in the simulator but not on the real device?

If this is not intended for the watch, why can I build this with no errors or warnings from the compiler?


Thanks,
Thomas
 
Source:

import Network
 
 
 
  // Network Stuff
   let monitor = NWPathMonitor()
//  let monitor = NWPathMonitor(requiredInterfaceType: .cellular)
//  let monitor = NWPathMonitor(requiredInterfaceType: .wifi)
   let queue = DispatchQueue(label: "InternetConnectionMonitor")
   var queueStarted:Bool = false
 
 
 
     monitor.pathUpdateHandler = { pathUpdateHandler in
       print( "\npathUpdateHandler = \(pathUpdateHandler)" )
       if pathUpdateHandler.status == .satisfied {
         DispatchQueue.main.async {
           print("Internet connection is on.")
       }
      } else {
         DispatchQueue.main.async {
           print("There's no internet connection.")
        }
      }
    }
     if !queueStarted {
       monitor.start(queue: queue)
       queueStarted = true
    }

 
 
Output:
 
pathUpdateHandler = unsatisfied (Path was denied by NECP policy), interface: ipsec0, ipv4)
There's no internet connection.
 

What is NECP?

NECP is the network interface access control subsystem. For example, on iOS, if you use Settings > Mobile Data to block an app from accessing WWAN, that’s enforced by NECP.

What is NECP Policy?

That should be obvious now that you know what NECP is.

Why does this work in the simulator but not on the real device?

Because the simulator uses the macOS networking stack and thus uses macOS NECP policies.

If this is not intended for the watch, why can I build this with no
errors or warnings from the compiler?

Because there are circumstances under which low-level networking will work on watchOS. See Low-Level Networking on watchOS.

Share and Enjoy

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

Thank you for the reply.

If I was writing a streaming or audio app, Would that mean NWPathMonitor would would as expected?

Thanks,
Tom

If I was writing a streaming or audio app, Would that mean
NWPathMonitor would would as expected?

I believe so. I haven’t actually tested NWPathMonitor but similar low-level networking APIs, like NWConnection, work just fine in a streaming audio context.

Finally, I want to stress that NWPathMonitor is working as expected here. It telling you that you don’t have access to the network and that’s 100% correct.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
NETWORK: NWPathMonitor non-functional on AppleWatch
 
 
Q