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

47 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Crashed: com.apple.root.default-qos EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000007
I am facing this error on my SDK project. Could not identify what's the actual issue. I've added the Firebase crash logs below. Crashed: com.apple.root.default-qos 0 libdispatch.dylib 0x1a778 dispatch_channel_cancel + 12 1 libdispatch.dylib 0x1a778 dispatch_source_cancel + 12 2 libsystem_dnssd.dylib 0x2084 DNSServiceProcessResult + 860 3 Common 0x2df04 __swift_memcpy5_4 + 25916 4 Common 0x10b00 block_destroy_helper.10 + 188 5 libdispatch.dylib 0x26a8 _dispatch_call_block_and_release + 32 6 libdispatch.dylib 0x4300 _dispatch_client_callout + 20 7 libdispatch.dylib 0x744c _dispatch_queue_override_invoke + 928 8 libdispatch.dylib 0x15be4 _dispatch_root_queue_drain + 392 9 libdispatch.dylib 0x163ec _dispatch_worker_thread2 + 156 10 libsystem_pthread.dylib 0x1928 _pthread_wqthread + 228 11 libsystem_pthread.dylib 0x1a04 start_wqthread + 8
2
0
801
Feb ’24
How to get full DNS responses from the system resolver? DNSServiceQueryRecord not returning errors..
I would like to get the full DNS responses from the system resolver. I'm using DNSServiceQueryRecord, but I can't get negative responses. How do I get the negative responses? I need the full response because they have clues about network-level censorship. For instance, mismatched case in the name, bad answer RR type, missing SOA record on no answers response. On Android I can use android_res_nquery, but I couldn't find anything similar on iOS and macOS. The closest I found was DNSServiceQueryRecord, which at least gives me resource records, so I can inspect TTL and name case. After some struggle, I was able to make it work. I'm using Go with cgo for that: https://github.com/fortuna/gio-test/blob/fortuna-dns/sysresolver_darwin.go https://github.com/fortuna/gio-test/blob/fortuna-dns/sysresolver_darwin_export.go My sequence of calls is: DNSServiceQueryRecord(sdRef, 0, 0, fullname, rrtype, rrclass, (DNSServiceQueryRecordReply)goCallback, context); fd := C.DNSServiceRefSockFD(sdRef) nReady, err := unix.Poll([]unix.PollFd{{Fd: int32(fd), Events: unix.POLLIN | unix.POLLERR | unix.POLLHUP}}, timeout) serviceErr = C.DNSServiceProcessResult(sdRef) // Here my callback gets called, multiple times for multiple answers. C.DNSServiceRefDeallocate(sdRef) I'm able to get positive answers, even multiple answers. But the Poll doesn't return when there are no answers (like for CNAME www.example.com). I expected the poll to return on negative answers, and my callback to be called with an error when calling DNSServiceProcessResult. Is that not the expected behavior? How do I get notified that a query has no answers?
2
0
580
Feb ’24
Apple devices can't ping each other in local network
Hi, I have a strange problem. In my local network, I have some apple devices (including mac, iphone, ipad) and a windows computer. The windows pc and any of the apple devices can ping each other, while every two of the apple devices can't ping each other. Whether udp or tcp are in the same situation. As is the situation, the firewall/mask/local ip are not the problems. I can't use wireshark to debug, because there is not any packet between these apple devices. Does someone know what the problem it may be? Or could someone tell me how to debug this? Thanks in advance!
2
0
870
Feb ’24
iOS 17 device undiscoverable via Bonjour ?
After upgrading to iOS 17 (now 17.2.1) on iPhone 11 pro the device does not appear to be discoverable on the local network via Bonjour. This is impeding, e.g., connecting to the device with iMazing etc. I looked at the local network with the Discovery app for Bonjour and while an iPad running iOS 16 is visible, the iPhone with iOS 17 is not. Any ideas ? We need to connect with iMazing via wifi since the mighty lightning port is predictably hosed for USB connection. Any insight appreciated. Thanks!
1
0
726
Dec ’23
NetService can't resolve(withTimeout:) service connected via ethernet for iOS 17.1+ (NSNetServicesErrorDomain: 10, NSNetServicesErrorCode: -72007)
It worked fine before iOS 17.1. Just checked with iOS 16 on real device. And my teammate from QA department confirmed it works for iOS 17.0.1. The problem occurs only with device in local network connected via ethernet. The device itself has two options for connection - via Wi-Fi and Ethernet. It works for all iOS versions via Wi-Fi. But it can't resolve host for Ethernet connection. Error appears in func netService(_ sender: NetService, didNotResolve errorDict: [String : NSNumber]) looks like that: (NSNetServicesErrorDomain: 10, NSNetServicesErrorCode: -72007) Could you please explain this error code?
1
0
656
Dec ’23
Confused about DNSServiceGetAddrInfo
I expect there is a shockingly obvious answer to this, but I've been stuck a couple of days on Problem Obvious and could use a tip / cake-with-file to escape from development jail. I have used DNSServiceRef / Bonjour to advertise my service, and have used the same to get a list of what is advertised (using the hit on lo0 for the moment since still testing). So, now I have a machine name "mymachine.local." and the right port number to connect to. Yay! What I can not figure out is how to get that information into a (IPV6) sockaddr so I can use it with connect. The point of confusion for me is that DNSServiceGetAddrInfo() does not take a port argument, and I see no other place to squeeze this information into the sockaddr returned by the DNSServiceGetAddrInfoReply. If I just use a IPV6 socket with that sockaddr, I get back EADDRNOTAVAIL. Haven't tried IPv4. No error is returned from DNSServiceGetAddrInfo. I'm reading around that this may be because the port is 0, and indeed I can't find any spot in this pathway to squeeze that information in. I'll attach an obligatory bit of code so that the reader may feel more grounded: // My DNSServiceGetAddrInfoReply void ServiceList::Node::AddressInfoCallback( DNSServiceRef __nonnull _sdRef, DNSServiceFlags _flags, uint32_t _interfaceIndex, DNSServiceErrorType _errorCode, const char * __nullable _hostname, const struct sockaddr * __nullable _address, uint32_t UNUSED _ttl, void * __nonnull context) { printf( "AddressInfo: \"%s\"\n", _hostname); AddrInfo * info = (AddrInfo*) context; if( kDNSServiceErr_NoError != _errorCode || NULL == _hostname || NULL == _address) { LOG_ERROR("Failed to get address info on \"%s\"\n", (const char*) info->hostTarget); delete info; return; } int err = connect(info->socket, _address, _address->sa_len); // returns EADDRNOTAVAIL on IPv6 socket. What am I really trying to do? I'd like to connect to the address and port that I from my DNSServiceResolveReply.
2
0
540
Dec ’23
Bonjour Conformance Testing - MDNS tests
Hey All, I'm currently trying to use the BCT v1.5.3 to validate the avahi mdns implementation. This is not so much to validate the avahi implementation but to actually understand how the BCT works. My setup is the following: the testing machine, where the BCT runs, is a 13-inch MacBook Pro 2019 the DUT (Device Under test) where avahi runs is a Linux machine (arch) and avahi runs version 0.8 I've tried several connection between the two: they have been connected point-to-point by a single network cable and the IPs have been set statically they have been connected via a router (that's not connected to the interned) both by cable and with IPs statically set connected via a router where the BCT computer is connected via cable and the DUT is connected via WIFI. My requirement is to run only the MDNS tests so the command I'm issuing on the BCT side is: sudo ./BounjourConformanceTest -M -I en4 -DD -V -Aip None -Amac None On the DUT side I start avahi as a daemon: sudo avahi-daemon And after that I also publish a service. I've done several tries but one that I think should be working is: sudo avahi-publish -s "My HAP Service" _hap._tcp 3213 [] I can see the three packets that make up the probing packets spaced out at 250ms each on wireshark both on the DUT and on the BCT device and the BCT prints: recv_packet 01997: received packet (96 bytes) recv_packet 01997: received packet (96 bytes) recv_packet 01997: received packet (96 bytes) But the tests doesn't seem to finish correctly. What am I doing wrong? Is my configuration incorrect/incomplete? Do I need to advertise a certain service? Thanks for the response in advance.
1
0
650
Dec ’23
Does Apple accept contributions for mDNSResponder?
We use the OSS release of mDNSresponder fairly extensively and have patched it to fix some issues. I was curious if Apple accepted such contributions upstream, or provided a way to communicate the changes for potential inclusion in future patches, as maintaining a fork isn't ideal for both parties. It seems that PRs on the GH repo are not always reviewed, but there is some evidence that they are looked at. We realise that POSIX implementation for mDNSResponder might not be a priority for Apple, but curious if there's a process for contributions from industry?
1
0
522
Dec ’23
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
1.7k
Dec ’23
Can you specify port for NWListener.Service without creating an NWListener on that port
I'm running a webserver for a specific service on port 8900 I'm using telegraph to run the webserver, so that opens and claims the port. I also want to advertise the service on bonjour - ideally with the correct port. This is trivial with NetService - but that's deprecated, so I should probably move to the Network framework. I can advertise without specifying a port listener = try NWListener(service: service, using: .tcp) but, then my service broadcasts addresses with port:61443 I can advertise using listener = try NWListener(using: .tcp, on: <myport>) however, that fails in my use case because (unsurprisingly) the Listener isn't able to get the port (my server already has it) Is this just a gap in the new API, or am I missing something?
1
0
529
Nov ’23
Bonjour discovery not working in iOS (NSNetServicesErrorDomain: 10, NSNetServicesErrorCode: -72008)
I'm currently trying to use an ESP8266, connecting to my home WiFi and starting a mDNS service. Then im trying to discover this service using the bonsoir package in flutter. So far so good. On Android everything works fine, but i want to use the app on the iPhone too. As far as i understood the information in this video 'developer.apple.com' i need to add this to my info.plist: <key>NSLocalNetworkUsageDescription</key> <string>Some understandable text for the user.</string> <key>NSBonjourServices</key> <array> <string>_http._tcp.</string> </array> I wrote a short python script which resolves the service in my network and im getting the following output: Service ESP8266Control._http._tcp.local. added, service info: ServiceInfo(type='_http._tcp.local.', name='ESP8266Control._http._tcp.local.', addresses=[b'\xc0\xa8\x02\xa0'], port=80, weight=0, priority=0, server='ESP8266Control.local.', properties={b'SN': b'10 - 00001'}, interface_index=None) Address: ['192.168.2.160'] Port: 80 Service Name: ESP8266Control._http._tcp.local. Server: ESP8266Control.local. Properties: {b'SN': b'10 - 00001'} My flutter app should be correct because on android everything works as expected. I tried to discover the service in my network by building my app on a mac book for ios. The popup for using the network appears with the defined message "Some understandable text for the user." and i have to confirm the usage of network discovery usage. But when i hit the button in my app to search for my wordclock, the following error is output: [discovery] [28317] Bonsoir has encountered an error during discovery : ["NSNetServicesErrorCode": -72008, "NSNetServicesErrorDomain": 10] [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(discoveryError, Bonsoir has encountered an error during discovery., {NSNetServicesErrorCode: -72008, NSNetServicesErrorDomain: 10}, null) Is my syntax wrong in my info.plist? I also tried to use this ESP8266Control._http._tcp. and several combinations with .local at the end, with and without the service name and with _http and _tcp seperated as 2 individual entries. I tried A LOT of combinations, but nothing changes anything. This is one of the combinations i've tried: <array> <string>_ESP8266Control._http._tcp</string> </array> <key>NSLocalNetworkUsageDescription</key> <string>Need access to connect with the clock itself.</string> <key>NSLocationAlwaysUsageDescription</key> <string>This app needs access to location when in the background.</string> <key>NSLocationWhenInUseUsageDescription</key> <string>This app needs access to your location to show nearby networks to connect the Wordclock to.</string> I would apprecciate help so much, we wasted so much time on this and the apple support told they can't help us... Best regards MeisterTubi
1
0
848
Nov ’23
Unable to obtain the IP of third-party hardware devices through MDNS in IOS17
I have some EPS8266 and ESP32 devices. I used to obtain the IPs of these devices through MDNS and then control them. However, after I upgraded to IOS17, the devices cannot be searched. I can see the name of the device in the Discovery APP, but the IP of the device cannot be loaded. IOS16 and below versions can search for devices normally. Is this intended functionality cut or just a bug?
1
0
465
Nov ’23
Network.Framework vs URLSession in Background Task (BGTask)
As noted here, https://developer.apple.com/forums/thread/116799 the Network framework probably won't have a connection available when running in the background. We've been using the BGTask for a couple years now to start a URLSession and pull data from a web server. It works very nicely and reliably. Do we have any options if we want to connect to another iPad, though? I ran a test and even if I have a "server" iPad running a Network framework listener (NWListener), and the app is in the foreground and the screen on, a "client" iPad (NWBrowser) cannot connect to the NWListener when trying to connect from the BGTask; it gives a DefunctConnection error. Why does the Network framework not have the network available to it, but a URLSession does? Is this a limitation of the iPad, or the Network framework? If I had an iPad running as a web server like this project, https://github.com/swisspol/GCDWebServer and an iPad client tries to connect a URLSession to it, would that work? If this is an iPad limitation, could I use a MacBook on the network as a web server and connect to that instead?
6
0
783
Nov ’23
How to create and advertise a Bonjour service with Network.framework?
I'm trying to create and advertise a Bonjour service via Network.framework. In Xcode, target, Info tab, I've added the entry to plist: And then written the following code: guard let listener = try? NWListener(service: .init(name: "My Printer Service", type: "_printer._tcp"),using: .tcp) else { return nil } self.listener = listener listener.stateUpdateHandler = { newState in switch newState { case.ready: print("starting") case .failed(let error): print("error: \(error)") default: print(newState) } } listener.start(queue: .main) However, the status is failed with error message: POSIXErrorCode(rawValue: 22): Invalid argument
1
0
773
Nov ’23
Network Framework with multiple clients
How can I use the Network framework to establish a "client-server" type relationship between a server iPad and, say, 3 client iPads? I've downloaded the TicTacToe sample app, https://developer.apple.com/documentation/network/building_a_custom_peer-to-peer_protocol which demonstrates nicely a connection between a PeerListener and a PeerBrowser. However, I then tried to make an array of PeerConnection objects rather than a single one, and send data to each one separately from the PeerListener. However, what appears to happen is that the 1st PeerBrowser connects successfully, but when the 2nd PeerBrowser connects, it replaces the 1st PeerBrowser, and both PeerConnection objects in the array point to the 2nd PeerBrowser, so when I send data via either PeerConnection, the data arrives at the 2nd PeerBrowser. Is it possible to do this? If so, how can I establish multiple PeerConnections between 1 "server" iPad and multiple "client" iPads?
2
1
600
Nov ’23
Local Network Privacy FAQ-18
This post is part of the Local Network Privacy FAQ. Can my app trigger the local network privacy alert when the device is on WWAN? Yes. While the local network privacy alert is most commonly seen when the device is on a Wi-Fi network, that’s not required. It’s possible for your app to trigger the local network privacy alert on a device that is on WWAN. Indeed, the alert can show up even if you: Leave the current Wi-Fi network in Control Center Turn Wi-Fi off in Settings Enable Airplane Mode in Settings Back to the FAQ
0
0
451
Oct ’23
NWTXTRecord dictionary keys are lowercased in iOS 17 beta
NWTXTRecord dictionary keys are lowercased in iOS 17, on iOS Simulator and the device. Records returned by NWBrowser in the listener block: browser.browseResultsChangedHandler = { result, changes in metadata : ["dvty": “AppName”, "txtvers": "1", "dbid": "50BFB79F"] But the actual keys are: "DvTy", "DbId". So, in iOS 17 all keys were lowercased, but not in any previous versions. And if in the app we were looking for “DvTy” key, nil is returned. The existing app simply stopped working properly in the first iOS 17 betas. Is it a bug or the app should be updated now to check for lowercased keys always? FB12309561
5
1
1.1k
Oct ’23
Happy Eyeball broken in iOS 16.0.2?
Hi, We have an app that make HTTP requests to a device on the local network using connect-by-name semantics and for which the name is resolved using mDNS aka mydevice.local. The HTTP request is made using a URLSession (internally using the React-native v0.68.1 fetch implementation) We have a latency problem in the case where the local network router IPv6 is not enabled, under certain conditions. Even though IPv6 is not enabled, our device mDNS resolver advertises the IPv6 AAAA address record of its link-local address (aka fe80::...). From our understanding this seems to be normal, it is the client responsibility to figure out how to contact the host. On iOS 16.0.2 and 16.1.1, we observe in Instruments that the app will first make an attempt on the IPv6 address record alone, timeout after 2 seconds and 3 retries, and then only try the IPv4 address record immediatly after the 3rd IPv6 attempt. For some reason the same name resolution attempts are made for every dataTaskWithRequest calls (even though the same session is reused and not invalidated). This is running on a real iPhone, but the same behavior is observed using the simulator 16.2 instead. The more or less same observation is made if we use Safari rather than our app. We have this latency of 2 seconds, but we can't confirm the same behavior with Instruments. We don't observe this problem on iOS 16.6 and 16.6.1, as well as the simulator running 15.2 (on the same computer running the simulator 16.2). Reading this excellent post and TN3151, we understand that our non-enabled IPv6 is mitigated using the "Happy Eyeballs" algorithm, for which 2 engineers at Apple refined the original algorithm in RFC8305 which is dated end of 2017. From this, we assume that the behavior we see on iOS 16.0.2 and 16.1.1 is incorrect. So for now we assume that this algorithm has been implemented since quite some time in iOS, and we are wondering if something is broken in iOS 16.0 and 16.1? As far as we understand, iOS 16 seems to conform to RFC6724 with an IPv6 preference in its default policy. We understand that all this is a lot of assumptions, but tracking this problem between platforms and accross implementations has been quite intense, so we want to know if we are looking in the right direction. From our observation, it seems that there is something really wrong with iOS 16.0.2 but we also can't believe that would have slip through during Apple beta-test phase either. So if there is something wrong on our side, what could it be? Thanks!
4
1
738
Oct ’23
How can I get devices connected to the same wifi network?
I need to get all devices names which are connected to same wifi. I tried NetServiceBrowser, in netServiceBrowser(_ browser: NetServiceBrowser, didFind service: NetService, moreComing: Bool) function I get some devices name like Macbook or iPad with search service type of browser.searchForServices(ofType: "_services._dns-sd._udp.", inDomain: "local.") But in this service type I cant get iPhones. I'm not sure if this is the right way, which framework should I use to accomplish this? Am I on the right track? What permits do I need to get? I need your help. Best regards.
3
1
702
Oct ’23