Post

Replies

Boosts

Views

Activity

Apple sample code: device-to-device connection breaks on second launch (tvOS 18.6 / iPadOS 18.3.2, 18.6)
Hello everyone, Last year I built an application for tvOS and iPadOS that enables device-to-device communication. I based it on Apple’s sample code, available here: https://developer.apple.com/documentation/Network/building-a-custom-peer-to-peer-protocol At that time, everything worked flawlessly. However, this year I had to revisit the project to add new features, and now it no longer works as expected. The first time the app runs it connects fine, but if we relaunch it (on either the iPad, the Apple TV, or both), the connection fails. Most importantly, this is not an issue with my own code — I tested it directly with the original Apple sample code, and the exact same problem occurs there too. Here’s what I see in the logs: nw_endpoint_flow_setup_channel [C1 TicTacToe,65E91B02-890E-4D30-88B8-CE2AB9677BF9 in_progress channel-flow (satisfied (Path is satisfied), viable, interface: utun0, scoped, ipv6)] nexus assignment error Connection refused nw_endpoint_flow_failed_with_error [C1 TicTacToe,65E91B02-890E-4D30-88B8-CE2AB9677BF9 in_progress channel-flow (satisfied (Path is satisfied), viable, interface: utun0, scoped, ipv6)] already failing, returning code-block This happens right after I select the iPad from the device list and try to connect. What’s strange is that the interface being used is utun0. I don’t have a VPN or iCloud Private Relay enabled. I also tried running the app through the iPad’s personal hotspot, but I get the same error. The only workaround I’ve found so far is to restart the Apple TV. Has anyone else run into this problem? Is there any known solution or workaround? Tested on tvOS 18.6 and iPadOS 18.3.2 / 18.6.
1
0
74
2w
iOS 17 mDNS IP resolving issue
Hello there, We have an iPad application which uses mDNS to find specific devices on the network then it resolves an IP address so then the application can connect to it through websocket. It has been working for years now. Recently our clients started to update their iPads to iOS 17 and suddenly this functionality stopped working. When I wanted to test out what's going on I found out that when I run the application on an iPad simulator on my macbook it can resolve the IP address immediately but when I run it on an iPad it cannot. That seemed weird so I decided to look into the code and I saw that the NetServiceBrowser api had been deprecated and I thought that maybe that's the problem so I refactored the code to use NWBrowser which was rather easy it found the service, but then when I wanted to meg an NWConnection to it the same error happened. From macOS it works fine but on the iPad the connection's state never gets ready, it hangs on the preparing state. I created a new test application just with this functionality to test it on an iPhone too. Well it seems that the issue is appearing on the iOS too. One other thing to mention, I created a simple node.js application which uses mDNS broadcast to simulate this device which we're trying to connect. The weird part that both the iPad and the iPhone can resolve it's address. I'm curious if something has changed since iOS 16, I couldn't find anything and I don't know where to go next, or how can somebody reproduce this error without the device. Any help is appreciated. Here is my discovery code: import UIKit import Network class ViewController: UIViewController { var browser: NWBrowser! override func viewDidLoad() { super.viewDidLoad() browser = NWBrowser(for: .bonjour(type: "_http._tcp", domain: ""), using: .tcp) browser.stateUpdateHandler = { newState in switch newState { case .failed(let error): print("NW Browser: now in Error state: \(error)") self.browser.cancel() case .ready: print("NW Browser: new bonjour discovery - ready") case .setup: print("NW Browser: ooh, apparently in SETUP state") default: break } } browser.browseResultsChangedHandler = { ( results, changes ) in print("NW Browser: Scan results found:") for result in results { switch result.endpoint { case let .service(name: name, type: _, domain: _, interface: _): // All of our device has 'justfit' in their name if name.uppercased().contains("JUSTFIT"){ print(name) let proto: NWParameters = .tcp if let opt = proto.defaultProtocolStack.internetProtocol as? NWProtocolIP.Options { opt.version = .v4 } let connection = NWConnection(to: result.endpoint, using: proto) connection.stateUpdateHandler = { state in if state == .ready { if let path = connection.currentPath, let endpoint = path.remoteEndpoint { switch(endpoint) { case let .hostPort(host: host, port: port): print("IP: \(host), port: \(port)") break default: break } connection.cancel() } } else { print(state) } } connection.start(queue: .main) } default: break } } } browser.start(queue: .main) } }
4
0
3.3k
Dec ’23