3.2.1 can't resolve services in winOS 2003

Help
uvdynamics
2010-10-25
2013-01-24
  • uvdynamics
    uvdynamics
    2010-10-25

    I need some help.  I've upgraded our jmdns from ver. 0.2 to 3.2.1 because we can resolved some services sporadically coming from win OS 2008/2008R2.  With ver. 3.2.1 we can discovered/resolved services now from win OS 2008/2008R2, but we have a problem.  Older version of win OS like 2003, it can resolved the services, even though it can discover it first.  It just discover the services but can't resolve it - it just sits there.  Is there anybody experiencing this kind of problem and also any help or idea that I'm missing or we need to do on those win OS 2008/2008R2 server.  Any help, info or suggestion is greatly appreciated.
    Thanks

     
  • Pierre Frisch
    Pierre Frisch
    2010-10-25

    Could you try reproducing the problem with top of tree. There quite a lot of bug fixes there…

    Are you saying the jmdns hang on service resolution? I would be surprised there is a timeout and you should get some answer back. Are you using the synchronous os the asynchronous API? If you would share some of your code we may be able to help you.

    Cheers

    Pierre

     
  • uvdynamics
    uvdynamics
    2010-10-27

    (1) I'll try to check-out the trunk and try that one.
    (2) The java client that is looking/discovering services via jmdns couldn't resolve the given server/services in a given time. I tried from 5 secs to 1 mins. but no successfull.  I says it found and added that services (through the ServiceListener) but it couldn't resolve that service within the given time limit.  We use this during login for our application.  It seems to be too long for the user to wait for about a min just to log-in and select the propert server/service to log-in.
    (3) Below is the server side code that register this service - which is a java web service and it included in our weblogic startup class routine.
        private static void registerZeroConf2()  {
        JmDNS jmdns = null;
    try {
    // This will avoid unnecessary logging for the new JmDns library
    ConsoleHandler handler = new ConsoleHandler();
    for (Enumeration<String> enumerator = LogManager.getLogManager().getLoggerNames(); enumerator.hasMoreElements();) {
                     String loggerName = enumerator.nextElement();
                     java.util.logging.Logger logger = java.util.logging.Logger.getLogger(loggerName);
                     logger.addHandler(handler);
                     logger.setLevel(Level.OFF);
                 }
    handler.setLevel(Level.OFF);

    jmdns = JmDNS.create();
    slog.info("***Created JmDNS, creating ServiceInfo … ***");

    String jmdnsName = jmdns.getName();
    jmdnsName = jmdns.getName().substring(0, jmdnsName.indexOf(".")) + "//PPES:" + port;
    ServiceInfo info = ServiceInfo.create(WEBSERVICES, jmdnsName, port, 0, 0,
    jmdnsName);
    slog.info("***Created ServiceInfo. " + info);

    slog.info("***Registering ServiceInfo… ***");
    jmdns.registerService(info);
    slog.info("***Registering ServiceInfo… done.***");

    // Ensure that the service is fully registered by retrieving the registered service from JmDNS object
    ServiceInfo info2 = jmdns.getServiceInfo(WEBSERVICES, jmdnsName, true, 3000);
    if (info2 != null) {
    slog.info("Registered ServiceInfo: " + info2);
    } else {
    slog.warn("The ServiceInfo " + info + "\n is not yet fully registered!");
    }
    } catch (Exception e) {
    slog.error("*** JmDNS RegisterZeroConf Initialization fails.  ***");
    slog.error(e.getLocalizedMessage(), e);
    } finally {
    }
        }

    (4) Below is the java swing client that will try to discover some web services available.
    public Map<String, String> getServices() {
    try {
    resolved = new AtomicInteger(0);
    added = new AtomicInteger(0);
    finished = new AtomicBoolean(false);
    discoveredServices = new HashMap<String, String>();

    final JmDNS jmdns = JmDNS.create();
    log.info("*** Created JmDNS Object ***");

    jmdns.addServiceListener(WEBSERVICES, createListener());
    log.info("*** Attached Web Services listener to JmDNS Object ***");

    long initdelay = 5000; // 5 sec
    try {
    Thread.sleep(initdelay);
    } catch (InterruptedException e) {
    log.error(e.getLocalizedMessage());
    }

    long elaspedTime = initdelay;
    long expiredTime = 60000; // 60 secs.

    while (added.get() > resolved.get()) {
    try {
    Thread.sleep(initdelay);
    elaspedTime = elaspedTime + initdelay;
    if (elaspedTime >= expiredTime) {
    log.info(String.format("*** JmDNS Discovery reach time limit of %s ***", expiredTime/1000));
    break;
    }
    } catch (InterruptedException e) {
    log.error(e.getLocalizedMessage());
    }

    log.info("*** Total Services Discovered: " + added.get() + " ***");
    log.info("*** Total Services Resolved: " + resolved.get() + " ***");
    }

    log.info("*** Finished: Total Services Discovered: " + added.get() + " ***");
    log.info("*** Finished: Total Services Resolved: " + resolved.get() + " ***");

    jmdns.close();

    } catch (Exception ex) {
    ClientExceptionHandler.process(ex, "JMDNS Intialization Error");
    }
    return discoveredServices;
    }

    private ServiceListener createListener() {
    ServiceListener listener = new ServiceListener() {
    @Override
    public void serviceAdded(ServiceEvent event) {
    added.incrementAndGet();
    log.info(String.format("*** Service Added #%s ***", added));
    log.info(event.getInfo().toString());
    }

    @Override
    public void serviceRemoved(ServiceEvent event) {
    discoveredServices.remove(event.getName());
    log.info(String.format("*** Service Removed: " + event.getInfo().toString() + " ***"));
    added.decrementAndGet();
    }

    @Override
    public void serviceResolved(ServiceEvent event) {
    resolved.incrementAndGet();

    ServiceInfo info = event.getInfo();

    log.info(String.format("*** Service Resolved #%s: %s", resolved, info.toString()));

    StringBuilder service = new StringBuilder("http://");
    service.append(info.getInet4Address().getHostName());
    //service.append(info.getHostAddress());
    service.append(":").append(info.getPort());
    discoveredServices.put(info.getName(),service.toString());
    }
    };
    return listener;
    }
    (5)  Any help or suggestion is greatly appreciated and again thank you for you help and time.
    Jun

     
  • Pierre Frisch
    Pierre Frisch
    2010-10-27

    I would try a few things. First verify that the service is properly registered by using an external tool to check it or running the jmdns browser and look that your service resolve.

    The service resolution should be very quick as it does not require waiting for the establishment of the DNS. To see what is discovered in the client you can try to print the jmdns object itself it will show you the cache as well as other information.

     
  • helene
    helene
    2011-10-18

    I know this post is too old now, but I wanted to say that I had the same problem as uvdynamics.
    With my proper user interface I couldn't get any service resolved unless a new service gets added orremoved. However, with JmDNS browser, everything works fine. After, I realized that the method
    public void valueChanged(ListSelectionEvent e){….}
    is almost the only difference between my user interface and the browser. Actually, the call to the method getServiceInfos(type, name) was missing and adding it (in my case, I put it inside the serviceAdded method) did perfectly the trick..
    Finally services get resolved accordingly :))