mDNS time to live

balix53
Posts: 27
Joined: Mon Jan 21, 2019 8:47 am

mDNS time to live

Postby balix53 » Mon Feb 25, 2019 3:24 pm

Hello,

I am using the mDNS APIs however I don't see any option to set the TTL of my mDNS service. The service is visible on an Android smartphone with the application "Service Browser" but only for a brief period of time (I would say one second).

However I need my service to be always visible and I can't find a solution to do that. Is there any workaround to be able to set the TTL of an mDNS service ?

For now the only way I have found for the service to be always visible is to register and unregister it continuously.

Here is a code sample of how I set my mDNS service

Code: Select all

const char* name =  "hostname";
const char* service = "myservice";
const char* protocol = "tcp";

mdns_init();
mdns_hostname_set(name);
mdns_service_add(NULL, service, protocol, 80, NULL, 0);

ESP_cermak
Posts: 69
Joined: Thu Nov 01, 2018 8:32 am

Re: mDNS time to live

Postby ESP_cermak » Mon Feb 25, 2019 4:16 pm

Hi balix53,

adding a service should be enough to make it visible continuously, no need to setup TTL. (unless there is a bug)
which version of IDF are you using?

just checked with release 3.2 and android service browser can see the service, but have to follow the underscore convention

Code: Select all

const char* service = "_myservice";
const char* protocol = "_tcp";

balix53
Posts: 27
Joined: Mon Jan 21, 2019 8:47 am

Re: mDNS time to live

Postby balix53 » Fri Mar 08, 2019 9:03 am

Indeed, the protocol must be prefixed with an underscore. I ended up using Bonjour Browser on Windows to see if my service was correctly registered and it works far better than Service Browser on Android. There should be no problem now.

Who is online

Users browsing this forum: No registered users and 126 guests