From: Nuno S. <nun...@im...> - 2014-01-17 15:58:28
|
Rick, My guesses from yesterday didn't seem to lead anywhere. I continued my search over the code and I have found something that has sorted my problem. Please look to the following diff on ListenerStatus.java: Index: src/main/java/javax/jmdns/impl/ListenerStatus.java =================================================================== --- src/main/java/javax/jmdns/impl/ListenerStatus.java (revision 353) +++ src/main/java/javax/jmdns/impl/ListenerStatus.java (working copy) @@ -58,10 +58,12 @@ String qualifiedName = event.getName() + "." + event.getType(); if (null == _addedServices.putIfAbsent(qualifiedName, event.getInfo().clone())) { this.getListener().serviceAdded(event); + /* ServiceInfo info = event.getInfo(); if ((info != null) && (info.hasData())) { this.getListener().serviceResolved(event); } + */ } else { logger.finer("Service Added called for a service already added: " + event); } @@ -116,6 +118,7 @@ private static final boolean _sameInfo(ServiceInfo info, ServiceInfo lastInfo) { if (info == null) return false; if (lastInfo == null) return false; + if (lastInfo.getPort()!=info.getPort()) return false; if (!info.equals(lastInfo)) return false; byte[] text = info.getTextBytes(); byte[] lastText = lastInfo.getTextBytes(); The _sameInfo method was not validating if the lastInfo port was the same as the current info. I have added that case and now it reports the new port. I'm still unsure about the need of that bit commented code. My guess is that if it is not commented, the serviceResolved is called without checking the new info. I have also changed constants to make the check more quick but i'm not including this changes here. I would like to have your input on this changes. Regards, Nuno Santos On 17/01/2014, at 00:23, Nuno Santos <nun...@im...> wrote: > Rick, > > I have passed more than 8 hours today trying to understand what is going on and I will try to resume what I found. > > jmDNS is reported with the correct port everytime the service is restarted. However, due to a caching problem, the last working port is reported. I have changed some constants in order to have a quicker cache cleaning and service discovery. > > Now please try to understand the following. I have placed debug output on clean cache method, which is giving me all the cached entries for a determined service. I will focus on my service. > > 1 - Service not running > > DNSCache Entries: > none > > 2 - Service added > > DNSCache add entries > > add entry with name: _livkontrol._tcp.local. key: _livkontrol._tcp.local. > add entry with name: BIGMAC._livkontrol._tcp.local. key: bigmac._livkontrol._tcp.local. > > First note here: two dns entries are inserted in cache. basically the same dns entry with a prefix. > > Service added : BIGMAC._livkontrol._tcp.local. info: [ServiceInfoImpl@1486975107 name: 'BIGMAC._livkontrol._tcp.local.' address: '(null):0' status: 'DNS: bigmac-home.local. state: probing 1 task: null', has NO data empty] > > 3 - Wait a bit > > DNSCache Entries: > > entry name: _livkontrol._tcp.local. key: _livkontrol._tcp.local. > entry name: BIGMAC._livkontrol._tcp.local. key: bigmac._livkontrol._tcp.local. > > 4 - Service closed > > Clean Cache: > Expired record with name: _livkontrol._tcp.local. key: _livkontrol._tcp.local. > Service removed : BIGMAC._livkontrol._tcp.local. > > 5 - Wait a bit > > DNSCache Entries: > > entry name: BIGMAC._livkontrol._tcp.local. key: bigmac._livkontrol._tcp.local. > > From my point of view this is the problem. When the service is removed, one of the DNSEntries expires but the other one doesn't, being kept in the cache. When the service is started again, the cache can find info for this key and reports the last port. > > > This was what I found and i'm pretty sure that with your help we can identify a proper solution for this problem. > > Looking forward to hear from you. > > With my best regards, > > Nuno Santos > > > On 15/01/2014, at 00:44, Rick Blair <ric...@ma...> wrote: > >> Hi Nuno, >> >> I think your case is fairly unique. Services typically dont change ports between runs. That is a service listens to a specific port and not some random one picked at startup. That is a service could be defined by the port it listens on. >> >> Is there anyway to pick a port and stay with it? >> >> Rick >> On Jan 14, 2014, at 3:27 PM, Nuno Santos wrote: >> >>> Hi Will, >>> >>> Thanks for your reply. >>> >>> My problem is the following. >>> >>> I have been using jmDNS and i'm experiencing a problem with service port caching. >>> >>> The lib detected the service, but if the service is stopped and started again, jmDNS reports the service with the last port. >>> >>> Have you ever experienced such phenomena? How did you workaround it? >>> >>> Thanks, >>> >>> Regards, >>> >>> Nuno >>> >>> On 14/01/2014, at 22:59, Will Hawkins <haw...@op...> wrote: >>> >>>> Yup. Ask away. >>>> >>>> On 01/14/2014 05:15 PM, Nuno Santos wrote: >>>>> Hi, >>>>> >>>>> I would like to discuss an issue i'm experiencing with jmDNS. Is there anyone currently using jmDNS actively on an Android application? >>>>> >>>>> Regards, >>>>> >>>>> Nuno Santos >>>>> ------------------------------------------------------------------------------ >>>>> CenturyLink Cloud: The Leader in Enterprise Cloud Services. >>>>> Learn Why More Businesses Are Choosing CenturyLink Cloud For >>>>> Critical Workloads, Development Environments & Everything In Between. >>>>> Get a Quote or Start a Free Trial Today. >>>>> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk >>>>> _______________________________________________ >>>>> Jmdns-discuss mailing list >>>>> Jmd...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/jmdns-discuss >>>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> CenturyLink Cloud: The Leader in Enterprise Cloud Services. >>>> Learn Why More Businesses Are Choosing CenturyLink Cloud For >>>> Critical Workloads, Development Environments & Everything In Between. >>>> Get a Quote or Start a Free Trial Today. >>>> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk >>>> _______________________________________________ >>>> Jmdns-discuss mailing list >>>> Jmd...@li... >>>> https://lists.sourceforge.net/lists/listinfo/jmdns-discuss >>> >>> >>> ------------------------------------------------------------------------------ >>> CenturyLink Cloud: The Leader in Enterprise Cloud Services. >>> Learn Why More Businesses Are Choosing CenturyLink Cloud For >>> Critical Workloads, Development Environments & Everything In Between. >>> Get a Quote or Start a Free Trial Today. >>> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk >>> _______________________________________________ >>> Jmdns-discuss mailing list >>> Jmd...@li... >>> https://lists.sourceforge.net/lists/listinfo/jmdns-discuss >> >> -- >> Tìoraidh! >> >> Rick Blair >> ric...@ma... >> >> >> > > ------------------------------------------------------------------------------ > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. > http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk_______________________________________________ > Jmdns-discuss mailing list > Jmd...@li... > https://lists.sourceforge.net/lists/listinfo/jmdns-discuss |