Giter Site home page Giter Site logo

mdnsjava's People

Contributors

posicks avatar vvdleun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mdnsjava's Issues

Maven POM not working

Using the maven pom from maven central does not work properly.

The problem seems to be the parent-artifact. Since the parent artifact mdnsjava-full is not known, the artifact mdnsjava (which was published to maven central) could not be entirely resolved.
I think, the problem is that developers of this package has mdnsjava-full in their local repository (e.g. they used mvn install). Therefore, they do not see that this parent artifact is actually missing...

So, either, the whole project, including mdnsjava-full and its dependencies must be published as well or the <parent> tag should be removed from the pom.xml

get prepared for "reflective access denied" in future java releases

example not working

Hi this example does not work
Lookup lookup = new Resolve("Test._org.smpte.st2071.service:service_v1.0._sub._mdc._tcp.local.");
ServiceInstance[] services = lookup.lookupServices();
for (ServiceInstance service : services)
{
System.out.println(service);
}

I can not find the Resolve class.
I would recommend you to add these examples as test in your project.

Regards Stefan

Concurrency issue in Lookup

java.util.ConcurrentModificationException
at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:966)
at java.util.LinkedList$ListItr.next(LinkedList.java:888)
at net.posick.mDNS.Lookup.lookupRecords(Lookup.java:271)
at net.posick.mDNS.Lookup.lookupServices(Lookup.java:325)
at net.posick.mDNS.MulticastDNSService$Register.register(MulticastDNSService.java:364)
at net.posick.mDNS.MulticastDNSService.register(MulticastDNSService.java:867)

Shouldn't junit dependency in POM have test scope?

Hi,

I noticed my application bundles JUnit in its production JAR files. After looking around, I think it is caused by the POM file of mDNSJava:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
</dependency>

Shouldn't the "test" scope be specified here as well, or is there a reason for its compile scope?

Kind regards (and many thanks for your work on this awesome library!),
Vincent

How to register proxy?

dns-sd can register proxy using dns-sd -P <Name> <Type> <Domain> <Port> <Host> <IP> [<TXT>...] (Register Proxy).

Thread safety issue: NullpointerException in setCacheMonitor

What steps will reproduce the problem?
1. Service shutdown and discovery

What is the expected output? What do you see instead?
Gets NullpointerException in:
public void setCacheMonitor(CacheMonitor monitor);
at
executor.shutdown();

What version of the product are you using? On what operating system?
2.1.5

Please provide any additional information below:

Get NullpointerException in executor.shutdown() when
having broken out executor.shutdown into method: shutdownExecutor(). This 
implies thread safety issue. Consider synchronizing calls to 
executor.shutdown() in some way.
See following code and attached png image and java source file:

    /**
     * Sets the CacheMonitor used to monitor cache data. Can be used to
     * implement Cache record refreshing.
     * 
     * @param monitor the CacheMonitor
     */
    public void setCacheMonitor(CacheMonitor monitor)
    {
        cacheMonitor = monitor;
        synchronized (lock) {
            if (cacheMonitor == null) {
                if (executor != null) {
                    shutdownExecutor(); //Broken out!
                    executor = null; //Probably set to null here(?)
                }
            } else {
                if (executor != null) {
                    shutdownExecutor(); //Broken out!
                }
                executor = Executors.newScheduledThreadPool(1);
                executor.scheduleAtFixedRate(new MonitorTask(this, this.cacheMonitor), 1, 1, TimeUnit.SECONDS);
            }
        }
    }

    private void shutdownExecutor() { //This method was broken out from above!
        new Exception("TRACE").printStackTrace();

        executor.shutdown();
    }

This modification lead to NullpointerException, though code is basically the 
same.
In between 'if(executor != null)'-check and executor.shutdown(), executor may be
set to null by another thread.

I have attached a source file with proposed changes. Please note though that 
they were not seriously thought through. Issues may still exist (deadlock?), 
though the new code seems to work. Changes are marked with //TODO ...

Original issue reported on code.google.com by [email protected] on 15 May 2014 at 11:49

Attachments:

This project does not contain a license.

Hi,

I´d like to perhaps use this project in another library.
However, I cannot do that unless I have a clear guideline on under which conditions I can use this.

I would suggest something like adding an Apache2 license.
If you agree, I can even bring up a PR for that.

Regards,
TTheCreator

Serverless Chat Client

Wit the intention to implement a Serverless Chat client, I want to use mdnsjava to register my application and to discover other clients in my local network.

Both works correctly in the beginning, but within 2 minutes, my client is not found anymore by other clients in my network.

How can I keep my registration active? Do I have to start an extra service, or implement extra functions in MyPresenceServiceListener?

discoverId = mDNSService.startServiceDiscovery( new Browse(serviceTypes), new MyPresenceServiceListener());

service = new ServiceInstance(serviceName, 0, 0, presence.getPort(), host, addresses, presence.toMap());
registeredService = mDNSService.register(service);

Services Successfully Registered: Service ("tester1@mymachine._presence._tcp.local." can be reached at "MYMACHINE.local." [MYMACHINE.local./192.168.2.9, MYMACHINE.local./fe80:0:0:0:e5c1:5739:49ad:3b0c] on port 2300

Great project

But it is sad, that original author do not migrate it to the github and don't 
upload to maven central repository, now exist many unofficial clones

https://github.com/search?utf8=%E2%9C%93&q=mdnsjava

Original issue reported on code.google.com by [email protected] on 15 Jun 2015 at 7:35

Responses never get processed

What steps will reproduce the problem?
1. Have 3 network adapters (I have VMWare Installed which adds 2)
2. Run with '-B _myservice _tcp'  to find _myservice._tcp.local

Expected to see a ResolverListener receive the Message object, but it never 
does.

WireShark shows MDNS responses arriving at the correct port, the 
DatagramProcessor receives the packets, but the PacketRunner is never executed.

Using revision 62 on the trunk - 2.1.6 SNAPSHOT (maven). Windows 7 Pro.


The NetworkProcessor class has a ThreadPoolExecutor processorExecutor.  This 
will have two long-running threads for each network interface.  Executors.java 
has 'CORE_THREADS_NETWORK_EXECUTOR' set to 5.  This means that all 5 thread 
pools are filled by the NetworkProcessors for the three interfaces.  When a 
datagram Packet arrives, line 176 of DatagramProcessor.java attempts to run the 
PacketRunner to process the incoming mDNS response.  Since all 5 threads are 
currently running, no new thread starts up to process the incoming packet, and 
the response never arrives at higher levels of the application.

To temporarily fix, set the CORE_THREADS_NETWORK_EXECUTOR value equal to two 
times the number of network interfaces plus three - I set mine to 10.

To correct, perhaps have a different pool for PacketRunners than for the 
NetworkProcessor.

Original issue reported on code.google.com by [email protected] on 8 Apr 2015 at 5:59

TXT record not properly translated to textAttributes

The key-values pairs in a TXT record are not always properly translated to a Map with the correct textAttributes, when the values contain white-spaces.

IN:
tester1@mymachine._presence._tcp.local. 4500 IN TXT "last=van Tester" "hash=SHA-1" "status=avail" "ver=NfJ3flxICtbypursw=" "msg=A Message with whitespace !" "node=http://www.igniterealtime.org/projects/smack" "email=null" "1st=Test1" "port.p2ppj=2300" "txtvers=1"

OUT:
registerService Services Successfully Registered: Service ("tester1@mymachine._presence._tcp.local." can be reached at "MYMACHINE.local." [MYMACHINE.local./192.168.2.9, MYMACHINE.local./fe80:0:0:0:e5c1:5739:49ad:3b0c] on port 2300
TXT: last="van", Tester="", hash="SHA-1", status="avail", ver="NfJ3flI83zSdUDzCEICtbypursw=", msg="A", Message="",

When browsing through the code, I would say that the error is in the split function of the ServiceInstance. A boolean 'inQuote' is declared and set, but not used.

Documentation on project home page needs correcting

Examples refer to "Resolve" object and "resolveRecords" when they should refer 
to the Lookup" object and "lookupRecords", for example.

I imagine the names changed at some point and the home page was not updated.

Original issue reported on code.google.com by [email protected] on 6 Aug 2015 at 9:28

New service names are not recognized automatically

I registered an RFC 2782 service name ("conecube"). With this service name, I tested the "Registering and Unregistering a Services" sample. But the mDNS implementation throws

Exception in thread "main" org.xbill.DNS.TextParseException: Name "conecube" is not a RFC2782 service name!
	at org.xbill.mDNS.ServiceName.<init>(ServiceName.java:99)
	at org.xbill.mDNS.ServiceName.<init>(ServiceName.java:37)
	at mDnsSampleServer.main(mDnsSampleServer.java:30)

Seems the implementation does not query for registered service names (now listed in a different list than originally maintained for RFC2782 - the new RFC for iana service names is RFC6335 - see https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=conecube)

Using the 2.1.6-SNAPSHOT as suggested in the mdnsjava page's textual description.

I did also review the MASTER/TRUNK version's ServiceName implementation. Here it's searching for a Service.protocol file, which is not contained in the MASTER branch's sources.

Infinite loop when registering a service and listening at the same time

In my specific use case I need to both listen mdns packages of my devices in the network and at the same time announce my application to the network. When I do this:

import net.posick.mdns.*
import org.xbill.DNS.Message
import org.xbill.DNS.Name

fun main() {

    val mDNSService = MulticastDNSService()

    val deviceListener = object : DNSSDListener {
        override fun serviceDiscovered(id: Any, service: ServiceInstance) {
            println("serviceDiscovered $service")
        }

        override fun serviceRemoved(id: Any, service: ServiceInstance) {
            println("serviceRemoved $service")
        }

        override fun receiveMessage(id: Any, m: Message) {
            println("receiveMessage $m")
        }

        override fun handleException(id: Any, ex: Exception) {
            ex.printStackTrace()
        }
    }

    val service = ServiceInstance(
        ServiceName("myservice._http._tcp.local."),
        0,
        0,
        8443,
        Name.fromString("myservice._http._tcp.local."),
    )

    mDNSService.startServiceDiscovery(Browse("_device-id._tcp.local."), deviceListener)

    println("Announcing my service $service")
    mDNSService.register(service)
}

I am getting a StackOverflowError

Announcing my service Service ("myservice._http._tcp.local." can be reached at "myservice._http._tcp.local." [---] on port 8443)
Exception in thread "main" java.lang.StackOverflowError
	at java.base/jdk.internal.reflect.Reflection.verifyMemberAccess(Reflection.java:141)
	at java.base/java.lang.reflect.AccessibleObject.slowVerifyAccess(AccessibleObject.java:715)
	at java.base/java.lang.reflect.AccessibleObject.verifyAccess(AccessibleObject.java:701)
	at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:673)
	at java.base/java.lang.reflect.Method.invoke(Method.java:560)
	at org.xbill.DNS.MulticastDNSUtils.getTargetFromRecord(MulticastDNSUtils.java:219)
	at net.posick.mdns.MulticastDNSCache.queryCacheForAdditionalRecords(MulticastDNSCache.java:331)
	at net.posick.mdns.MulticastDNSCache.queryCacheForAdditionalRecords(MulticastDNSCache.java:338)
	at net.posick.mdns.MulticastDNSCache.queryCacheForAdditionalRecords(MulticastDNSCache.java:338)
	at net.posick.mdns.MulticastDNSCache.queryCacheForAdditionalRecords(MulticastDNSCache.java:338)
	...

What am I doing wrong here?

Automatically advertise on all ports

With the macOS equivalent API, I don't have to pass a list of addresses for where the server is, but rather, it automatically advertises on all ports, without me having to specify. (And provides no means to specify it if I wanted to...)

Having a way to do this with mdnsjava would be nice, because I can't really be sure whether network interfaces will come and go throughout the lifetime of the service, and re-registering services when that happens is a bit of a hassle.

Examples seem to be out of date

The examples in the readme appear to be out of date. From what I've tried it looks like DNSSDListener now requires a receiveMessage method but more seriously, the Browse.start method takes a ResolverListener instead of a DNSSDListener.

Can you post working examples?

Thanks,

Logan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.