WatchOS Network Framework connecting to Bonjour NWBrowser not working

Hello,

I'm working on an Apple Watch/ iPhone/PC/Mac OS sport applications with different types of connectivity and i'm a bit stuck with the bellow issue.

I'm trying to Resolve a Bonjour that is using NWBrowser on WatchOS 8.6 on Apple Watch SE with LTE and i encounter strange issues:

First i'm setup a NWBrowser :

NWBrowser(for: .bonjourWithTXTRecord(type: "_angry._tcp", domain: nil), using: parameters)

Then, using :

browser?.browseResultsChangedHandler = { [weak self] results, changes in

Everything works well until here

I'm gathering info form name and txt of the service found and ask the client if i want's a connection to service found . Using NWConnection to connecting to the found enpoint:

NWConnection(to: endpoint, using: params)

Here starts the issue In the stateUpdateHandler :

connection?.stateUpdateHandler = { state in
    switch state {
    case .ready:
     if let innerEndpoint = connection?.currentPath?.remoteEndpoint,
       case .hostPort(let host, let port) = innerEndpoint {

i'm checking the port and host where i'm getting the wrong informations, an IPV6 and a port that don't exists on the target server and a log in the console :

2022-05-22 15:54:33.146148+0300  WatchKit Extension[956:609596] [] nw_endpoint_proxy_copy_synthesized_url Endpoint type is not an address or host, cannot synthesize URL
2022-05-22 15:54:33.319537+0300 
 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching
2022-05-22 15:54:33.319604+0300 
WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching
2022-05-22 15:54:33.319621+0300 
WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching
2022-05-22 15:54:33.319636+0300  
WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching
2022-05-22 15:54:33.319651+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching
2022-05-22 15:54:33.501821+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching
2022-05-22 15:54:33.501875+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching
2022-05-22 15:54:33.501892+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching
2022-05-22 15:54:33.501908+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching
2022-05-22 15:54:33.501923+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching

I tried this on an apple watch simulator and a couple of real iPhone devices and everything works well, i'm getting the good port and host and no console errors/warnings.

PS: All this are done during a running HKWorkoutSession to ensure that the app is kept active during different networking operations.

What i'm doing wrong since is working fine on iPhone and WatchOS Simulator?

Thanks , Angry Software

Replies

I tried this on an apple watch simulator and a couple of real iPhone devices and everything works well

I believe you’re bumping into the limitation discussed in Low-Level Networking on watchOS.

Share and Enjoy

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

Thanks for answer eskimo !

I believe you’re bumping into the limitation discussed in Low-Level Networking on watchOS.

The issue that is if i do the connection to the server with ip and port directly everything works well. connection?.currentPath?.remoteEndpoint has correct data.

Do you know if there is any new news of low-level networking on WatchOS or if there is any plan to fully support all network framework features for WatchOS ?

Thanks,

Florin

Angry Software

Do you know if there is any new news of low-level networking on watchOS

Things are changing in this space and, sadly, I haven’t had time to dig into all the details. However, I did touch base with the Network framework team about this recently (in the last few months, so in the watchOS 8.x timeframe) and they confirmed that that post still accurately describes what we support.

if there is any plan to fully support all network framework features for watchOS ?

I can’t comment on The Future™.

Share and Enjoy

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

Thanks for your answers Eskimo.

I will keep digging in this area, this is quite important for my Apps and maybe ask this at WWDC 22 if will be sessions on Networking area. I will post here if get more info that might help the community in this matter.

Thanks, Florin Angry Software