Bonjour, also known as zero-configuration networking, enables automatic discovery of devices and services on a local network using industry standard.

Posts under Bonjour tag

49 Posts
Sort by:
Post not yet marked as solved
6 Replies
1.8k Views
NetServiceBrowser service always fails on iPhone if we create build from xcode 12. // We are using following line in to start searching for sevices available on network //         self.serviceBrowser.searchForServices(ofType: "_http._tcp.", inDomain: "local.")    It return following error dicitonary : ["NSNetServicesErrorCode": -72008, "NSNetServicesErrorDomain": 10] I did not find -72008 in error codes for NSNetServicesErrorDomain. It works as exepcted with previous vesions of Xcode. With Xcode 12 it works only on Simulator.
Posted Last updated
.
Post marked as solved
22 Replies
3.1k Views
Hi, I'm new to swift programming and right now writing an app for esp8266-controlled lamp device. My lamp is broadcasting it's own IP through bonjour. So all I want is to discover any lamps in my network (http.tcp) and to read name and value. Is there any example of such implementation? All I found so far is old or a lit bit complicated for such simple question. Thanks in advance!
Posted
by tarantino.
Last updated
.
Post not yet marked as solved
1 Replies
476 Views
I made a simple personal-use/testing watchOS app with a button that toggles the "mic muted" state of a chat application for Mac while on the same network. I'm now thinking about adapting this into a proper, distributable app with a companion Mac app. This has me wondering: Is there some solution in Apple's various frameworks that would allow me to "broadcast" a request of this sort from my watch, either over the cloud or over the local network, to my companion Mac app without much in the way of user configuration? My current solution of "make an HTTP request to the hardcoded URI of a server running on my Mac" obviously isn't adaptable to different users or devices. I considered Bonjour but it seems to be partially/fully deprecated and probably wouldn't let the user ensure only their own devices are controlled. Perhaps Handoff or something on CloudKit could be used for this purpose?
Posted
by tague.
Last updated
.
Post not yet marked as solved
1 Replies
475 Views
In short, I’m curious if multicast traffic (in general) is forwarded via IOS’s native IKEv2 VPN tunnel? (“road warrior”)… More specifically, I'm trying to understand how that may influence mDNS/Bonjour traffic? NOTE: The way that I am framing this discussion is inherently IPv4/IGMP-centric, although if there's a substantive IPv6 difference, that clarification would also be appreciated. Is there an obvious scenario where mDNS/SSDP/Bonjour name resolution of "something.local” or just “something” (hostname without FQDN) would be resolved on the IP-network associated with the physical ethernet interface / broadcast IP subnet of the end user Apple IOS device (either wifi or LTE), rather than the virtual interface of the VPN? For instance, if the IOS/BSD kernel processing expressly treats multicast differently from unicast traffic, then it’s conceivable that an IKEv2 tunnel could be established, and yet multicast could be operated in a “split-tunnel” mode where (intentionally, or even due to a race condition) mDNS/bonjour traffic emanates locally, or possibly across all interfaces, regardless of preferred-default route? I was hoping you would respond to this query with an answer like: The IKEv2 (road Warrior) VPN ensures all traffic, including broadcast + multicast are exclusively routed to the remote VPN endpoint, with no leakage... or There are known scenarios where multicast or broadcast traffic can operate effectively as a split-tunnel to the unicast traffic routing over the IKEv2 VPN, and if mDNS name resolution is of concern to you, you should review ________ for how to use MDM services to control that. Thank you!
Posted Last updated
.
Post not yet marked as solved
13 Replies
1.2k Views
Calling DNSServiceNATPortMappingCreate returns kDNSServiceErr_NoError like expected but the port mapping actually fails right away in the callback. I'm calling this in a daemon via XPC. Are there new restrictions or permissions required?
Posted
by Lucky7.
Last updated
.
Post marked as solved
8 Replies
5.7k Views
My app has to find a certain bonjour service on the local network and my code works fine for iOS 12/13 as well as macOS Big Sur and Catalina. The exact same code fails on iOS and iPadOS 14 with this error: ["NSNetServicesErrorDomain": 10, "NSNetServicesErrorCode": -72000] Which I have looked into and -72000 is an "Unknown error". I am using NetServiceBrowser to find the service and here is my code: class Bonjour: NSObject {     var discovered: [DiscoveredInstance] = []     let bonjourBrowser = NetServiceBrowser()     var discoveredService: NetService?     override init() {         super.init()         bonjourBrowser.delegate = self         startDiscovery()     }     func startDiscovery() {         self.bonjourBrowser.searchForServices(ofType: "_some-service._tcp.", inDomain: "local")     } } extension Bonjour: NetServiceBrowserDelegate, NetServiceDelegate {     func netServiceBrowser(_ browser: NetServiceBrowser, didFind service: NetService, moreComing: Bool) {         discoveredService = service         discoveredService?.delegate = self         discoveredService?.resolve(withTimeout: 3)     }     func netServiceBrowser(_ browser: NetServiceBrowser, didNotSearch errorDict: [String : NSNumber]) {         print(errorDict)     }     func netServiceBrowser(_ browser: NetServiceBrowser, didRemove service: NetService, moreComing: Bool) {         self.discovered.removeAll { $0.name == service.name }     }     func netServiceDidResolveAddress(_ sender: NetService) {         if let data = sender.txtRecordData() {             let dict = NetService.dictionary(fromTXTRecord: data)             /// do stuff with txtRecord dict here and then add to discovered array.             discoveredService = nil         }     } } I have no idea what could be causing the error and have tried enabling networking permissions and capabilities but have not been able to stop the error from occurring. Thanks.
Posted
by Priva28.
Last updated
.
Post not yet marked as solved
1 Replies
1.3k Views
Hello, Our app (OceanDMX Colours) can't communicate with their device over the network, because Local Network access is not applied in the iOS15 Settings. It does not ask about permission when installing and does not show in the Settings App -> Privacy -> Local Network. Was working fine until the release of the iOS 15. We did multiple tests and it works fine with older version of iOS (14.8), when installing it ask for permission and shows up in Settings App -> Privacy -> Local Network with the toggle option. Any ideas how to solve this issue? Has anyone run into the same problem?
Posted
by oceanL.
Last updated
.
Post marked as solved
2 Replies
354 Views
My company's app uses the following code to look for services advertised by a Garmin VIRB 360 camera (now discontinued and unsupported). In the past this code has worked fine. However, on my iPhone 12 Pro Max running iOS 15.0.2 it returns no services. let serviceBrowser = NetServiceBrowser() serviceBrowser.searchForServices(ofType: "_garmin-virb._tcp.", inDomain: "local.") Did something change in iOS 15? Do I need some entitlement? Is the format of the strings incorrect? My recollection is that the strings are from Garmin document (but its years old). Any help greatly appreciated!
Posted
by dhoerl.
Last updated
.
Post not yet marked as solved
0 Replies
237 Views
Hi Does anyone know what the Bonjour service that advertises mirror.dca.local is used for ? I upgraded from 14.4 to 14.7.1 and see that my phone is broadcasting this using multicastDNS / Bonjour. Merci beaucoup
Posted Last updated
.
Post not yet marked as solved
3 Replies
390 Views
I am able to send json data between NWConnection and NW Listener. I need help to send photo or any file to each other. I am using TCP protocol for data transfer. Please let me know how can I send any file. Thank You
Posted Last updated
.
Post not yet marked as solved
2 Replies
561 Views
Hello, I am trying to write an iOS app which could receive and analyze mDNS queries. More specifically, I have my app register a Bonjour service, and I need to see queries from the network for any subtype of my primary type, although I have not registered any subtype myself. Reason being that I have a device that tries to find me using a specific primary type, but always includes a subtype in its queries, and I can't know the subtype in advance, so I can't register my service with the subtype. So I'd need to see the query, extract the subtype and re-register my service with that subtype so that the device can then find me. Looks like the various APIs to interact with Bonjour won't let me do that. I've tried another approach and started a NWListener on port 5353 with allowLocalEndpointReuse set to true, but I'm getting "Address already in use" and it doesn't work, since this port is likely to be used by the mDNSresponder service. Is there an API I could use to achieve what I described above ?
Posted
by Goudalf.
Last updated
.
Post not yet marked as solved
3 Replies
503 Views
Hello everyone. I made a minimal example with DNS proxy. It works well on iOS 12, and doesn't work on iOS 14 (proxy runs well, but websites don't load). Traffic on iOS 14: 2 DNS queries (type A and type 65) + 2 successful DNS responses and it's all (there are no more IP packets). DoH / DoT are disabled. In logs everything is OK (no errors, everywhere are the same number of packets (read from NEAppProxyUDPFlow = sent to NWConnection = received from NWConnection = written to NEAppProxyUDPFlow). There are no TCP connections. Thanks in advance for any ideas / suggestions. import NetworkExtension //import DNS class DNSProxyProvider: NEDNSProxyProvider {       override init() {     super.init()   }   override func startProxy(options: [String: Any]? = nil,                completionHandler: @escaping (Error?) -> Void) {     completionHandler(nil)   }   override func stopProxy(with reason: NEProviderStopReason,               completionHandler: @escaping () -> Void) {     completionHandler()   }   override func sleep(completionHandler: @escaping () -> Void) {     completionHandler()   }   override func wake() {}       override func handleNewFlow(_ flow: NEAppProxyFlow) -> Bool {     if let tcpFlow = flow as? NEAppProxyTCPFlow {       NSLog("MyDebug: TCP connection")     } else if let udpFlow = flow as? NEAppProxyUDPFlow {       NSLog("MyDebug: UDP connection")       establishConnection(flow: udpFlow)       openFlow(flow: udpFlow)     }     return true   }   private func openFlow(flow: NEAppProxyUDPFlow) {     flow.open(withLocalEndpoint: nil) { opnErr in       if let e = opnErr {         NSLog("MyDebug: open error - \(e.localizedDescription)")       } else {         NSLog("MyDebug: open - ok")       }     }   }       private func establishConnection(flow: NEAppProxyUDPFlow) {     let conn = NWConnection(host: "8.8.8.8", port: 53, using: .udp)     conn.stateUpdateHandler = { state in       switch state {       case .ready:         NSLog("MyDebug: establishConnection ready")         self.send(flow: flow, connection: conn)       case .setup:         NSLog("MyDebug: establishConnection setup")       case .cancelled:         NSLog("MyDebug: establishConnection cancelled")       case .preparing:         NSLog("MyDebug: establishConnection preparing")       default:         NSLog("MyDebug: establishConnection default")       }     }     conn.start(queue: .global())   }       private func send(flow: NEAppProxyUDPFlow,            connection conn: NWConnection) {     flow.readDatagrams { (datagrams, endpoints, rdErr) in       let datas = self.extractReadData(rdErr: rdErr, datagrams: datagrams)       for packet in datas {         conn.send(content: packet,              completion: .contentProcessed( { sndErr in               if let e = sndErr {                 NSLog("MyDebug: send error - \(e.localizedDescription)")               } else {                 NSLog("MyDebug: send - ok")                 self.receive(flow: flow, connection: conn)               }         }))       }     }   }       private func extractReadData(rdErr: Error?,                  datagrams: [Data]?) -> [Data] {     if rdErr == nil, let datas = datagrams, !datas.isEmpty {       NSLog("MyDebug: read - ok")       return datas     } else {       if let e = rdErr {         NSLog("MyDebug: read error - \(e.localizedDescription)")       } else {         NSLog("MyDebug: read - datagrams is empty or null")       }       return []     }   }       private func receive(flow: NEAppProxyUDPFlow,              connection conn: NWConnection) {     conn.receiveMessage { (data, context, isComplete, rcvErr) in       let d = self.extractReceivedData(data: data, isComplete: isComplete, rcvErr: rcvErr)               flow.writeDatagrams([d], sentBy: [flow.localEndpoint!]) { wrtErr in         if let e = wrtErr {           NSLog("MyDebug: write error - \(e.localizedDescription)")         } else {           NSLog("MyDebug: write - ok")         }       }     }   }       private func extractReceivedData(data: Data?,                    isComplete: Bool,                    rcvErr: NWError?) -> Data {     if isComplete, rcvErr == nil, let d = data {       NSLog("MyDebug: receive - ok")       return d     } else {       if let e = rcvErr {         NSLog("MyDebug: receive error - \(e.localizedDescription)")       } else {         NSLog("MyDebug: receive - isComplete = \(isComplete); data = \(data)")       }       return Data()     }   } }
Posted
by algol-21.
Last updated
.
Post not yet marked as solved
8 Replies
621 Views
What is "NetworkConstants.serviceName" "NetworkConstants.serviceType" in NetworkListener Class will you please suggest me. And func didReceivedData(connection: NetworkConnection, with messageResponse: ConnectionMessage) what should be in "ConnectionMessage" and each of in "NetworkConnection" Class. Reagards, Narendra Sorathiya
Posted Last updated
.
Post marked as solved
2 Replies
452 Views
I’m, using NSNetService in macOS & iOS to advertise a network service that is written in a cross-platform way using C++. Using the new Network framework, advertising via NWListener.Service seems only possible if the network interface is also written using NWListener. How can I advertise my network service via Bonjour without using the now deprecated NSNetService? Thanks for any advise.
Posted
by Fritzt.
Last updated
.
Post not yet marked as solved
23 Replies
5.6k Views
Hi, I am facing a strange issue in my app with iOS14 there is a intermittent crash, i am using NetServiceBrowser for MDNS discovery not sure if that is causing the problem crash log has below information: Crashed: com.apple.main-thread 0 CoreFoundation 0x1a906c4c4 CFAssertMismatchedTypeID + 108 1 CoreFoundation 0x1a8f7db0c CFRunLoopSourceRemoveFromRunLoop + 298 2 CFNetwork 0x1a96255b0 CFNetServiceBrowserStopSearch + 460 3 CoreFoundation 0x1a8f81240 CFRUNLOOPISCALLINGOUTTOASOURCE0PERFORMFUNCTION + 24 4 CoreFoundation 0x1a8f81140 CFRunLoopDoSource0 + 204 5 CoreFoundation 0x1a8f80488 CFRunLoopDoSources0 + 256 6 CoreFoundation 0x1a8f7aa40 CFRunLoopRun + 776 7 CoreFoundation 0x1a8f7a200 CFRunLoopRunSpecific + 572 8 GraphicsServices 0x1bf075598 GSEventRunModal + 160 9 UIKitCore 0x1ab840004 -[UIApplication run] + 1052 10 UIKitCore 0x1ab8455d8 UIApplicationMain + 164
Posted Last updated
.
Post not yet marked as solved
1 Replies
407 Views
Im trying to develop an app, which will do a TCP connection with the local network device and perform some trigger event with the local network device. Basically to get some input from the app and display it on the local network device. Is there any standard I have to follow if Im doing this?
Posted Last updated
.
Post not yet marked as solved
6 Replies
562 Views
We are working on a project that communicates location data via a network. We are able to get the Location Services to work using: <key>NSLocationAlwaysAndWhenInUseUsageDescription</key> <string>Location data will be used to monitor your position</string> <key>NSLocationWhenInUseUsageDescription</key> <string>Location data will be used to monitor your position</string> And we able to get the networking functionality to work using: <key>NSBonjourServices</key> <array> <string>_appName-data._tcp</string> <string>_appName-data._udp</string> <string>_appName-chat._tcp</string> <string>_appName-chat._tcp</string> </array> and <key>NSLocalNetworkUsageDescription</key> <string>appName needs to use your phone&apos;s data to discover devices nearby</string> However, we are only able to use these independently. When both are included together, the NSBonjourServices quits working, but the location services works. Any one know what needs to be done to have both working together?
Posted Last updated
.
Post not yet marked as solved
3 Replies
534 Views
Hi all, I'm relatively new to posting in forums, but here we go. I am currently working on an enterprise platform for iPad, and we've decided to implement Network framework to link the iPads of a particular location together for data transfer. Basically the iPads will be constantly kept in sync with one another by changing each iPad's Core Data memory store accordingly. This works great when all iPads are within range! However, when an iPad leaves the area and returns, it does not catch the updates of the others or send out its own updates efficiently. It sometimes gets them, sometimes does not. There is a lot of nuance to networking code that I'm not familiar with yet, and I frequently get very low-level network errors that I do not understand very well, and which yield little to no search results when looked up. There aren't a lot of examples out there, and I'm not sure I've set up the network to do peer to peer properly, which is reflected in the errors I wanted to ask about. There are two in specific, one is far less reproducible. The first yields a crash log, so if anyone can point me to a tool to debug this one that would be great. It also does not crash the app or cause permanent functionality loss, but that's not a good reason to ignore a bug, as that could be very different in production. I'd like to know how to handle this correctly. I have some basic print debug statements on the fail states of NWBrowser, NWConnection, and NWListener, and none of them are ever hit when these particular errors surface. __nwlog_err_simulate_crash simulate crash already simulated nw_channel_disconnect_flow protocol ip_listener has invalid disconnected callback, dumping backtrace:     [arm64] libnetcore-2288.140.7   0  libnetwork.dylib          0x00000001a14e9d2c __nw_create_backtrace_string + 120   1  libnetwork.dylib          0x00000001a1177b28 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 3210024   2  libnetwork.dylib          0x00000001a11865a0 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 3270048   3  libnetwork.dylib          0x00000001a1184964 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 3262820   4  libnetwork.dylib          0x00000001a118335c 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 3257180   5  libnetwork.dylib          0x00000001a1182da4 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 3255716   6  libnetwork.dylib          0x00000001a146f124 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 6320420   7  libnetwork.dylib          0x00000001a13d9f0c 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 5709580   8  libnetwork.dylib          0x00000001a13d9b34 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 5708596   9  libnetwork.dylib          0x00000001a13d92bc 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 5706428   10 libnetwork.dylib          0x00000001a1180888 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 3246216   11 libnetwork.dylib          0x00000001a117e2b0 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 3236528   12 libnetwork.dylib          0x00000001a117d91c 40081C9D-213A-3EFC-8E66-3FC0E3110449 + 3234076   13 libdispatch.dylib          0x0000000102555de0 _dispatch_client_callout + 20   14 libdispatch.dylib          0x0000000102558ed0 _dispatch_continuation_pop + 616   15 libdispatch.dylib          0x000000010256eca0 _dispatch_source_invoke + 1384   16 libdispatch.dylib          0x0000000102560324 _dispatch_workloop_invoke + 2200   17 libdispatch.dylib          0x000000010256ba50 _dispatch_workloop_worker_thread + 1600   18 libsystem_pthread.dylib       0x00000001eb4c27a4 _pthread_wqthread + 276   19 libsystem_pthread.dylib       0x00000001eb4c974c start_wqthread + 8 The other error is about a TCP listener failing to receive data within a time limit, and the connection in that instance will permanently die. Meaning, the iPad will never communicate with the others again after that. I haven't seen that one since I made some changes, but I'd rather be sure it is addressed. However it again has to do with connections, which leads me to suspect I haven't got them set up quite right. Has anyone encountered these issues before, or done something similar and can provide a bit of direction? I would love some insights 🙇‍♂️
Posted Last updated
.
Post not yet marked as solved
5 Replies
527 Views
I am currently working on an iOS application that would ideally allow end users to create a VPN connection, find the server with Bonjour (NWBrowser) and then connect to it and then view media files using a media browser I built that runs locally on the server. I've already built a Mac OS X application that can perform the functionality in question, but iOS is a bit different. Is this possible?
Posted
by OWCjake.
Last updated
.