Sorry for the confusion. I assume it is step 3, that the connection is made, but it is still in the preparing state.
self.netConnect?.stateUpdateHandler = { (newState) in
With _ssh._tcp. newState never gets past preparing whereas the other service _mik._tcp. gets to ready
Post
Replies
Boosts
Views
Activity
Unfortunately, 16.3 doesn't resolve the issue. The WebRTC Library used in this app we are unable to test in the Simulator at this time (we are working on making that happen).
Thank you for your reply. the failure I am seeing is a bit deeper in the process, not with the NWBrowser, but with the NWConnection I am ultimately using to resolve the ipaddress.
Below, you will see my extra code that I added to the sample you provided above. I use the changes to create a NWConnection
Is there a simpler way to get the ipaddress?
self.browser.browseResultsChangedHandler = { services, changes in
self.services = services.map { result in
guard case .service(name: let name, type: _, domain: _, interface: let interface) = result.endpoint else { fatalError() }
return Service(name: name, endpoint: result.endpoint, interface: interface, connection: nil)
}
print("SERVICES \(self.services)")
for change in changes {
if case .added(let added) = change {
switch added.endpoint {
case .service(name: let name, type: let type, domain: let domain, interface: let interface):
self.netConnection = NWConnection(to: .service(name: name, type: type, domain: domain, interface: interface), using: .tcp)
print("netConnection stateUpdateHandler start")
self.netConnection?.stateUpdateHandler = { (newState) in
//with _ssh._tcp. this new state below never gets past `preparing`. With the other type, it goes to `ready` then I get the host
print("netConnection newState \(newState)")
switch (newState) {
case .ready:
guard let currentPath = self.netConnection?.currentPath else { return }
if let endpoint = currentPath.remoteEndpoint {
switch endpoint {
case .hostPort(host: let host, port: _):
switch host {
case .ipv4(_):
//this is where I get the ipaddress ...
print("host ipv4: \(host.debugDescription)")
case .ipv6(_):
//this is where I get the ipaddress ...
print("host ipv6: \(host.debugDescription)")
default:
print("host: not found")
break
}
default:
break
}
}
default:
break
}
}
default:
break
}
}
}
self.netConnection?.start(queue: .main)
This is a HUGE issue for me! I am working on an IoT app that uses NEHotspotConfiguration to switch to the wifi network of a device to stream video. Once I connect to the IoT device, the connection to Xcode is lost. This is so hard to develop now, and since I am running Sonoma, I cannot revert to an older version of Xcode. And tuning off Wifi is not an option since that is required for the app to connect to the device.