Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to initialize MulticastReceiverImpl. Port 1900 already in Use #227

Open
JasonMahdjoub opened this issue Feb 15, 2018 · 4 comments

Comments

@JasonMahdjoub
Copy link

Hi,

I use Cling in order to detect the local router of the lan, and to tell it to open a port with the current computer. I have made some tests, and they work under Linux and under Windows. However, I can't do these tests under MacOS. Here the log of Cling :

org.fourthline.cling.UpnpServiceImpl INFOS : >>> Starting UPnP service...
org.fourthline.cling.UpnpServiceImpl INFOS : Using configuration: com.distrimind.madkit.kernel.network.DefaultUpnpServiceConfiguration
org.fourthline.cling.transport.Router INFOS : Creating Router: org.fourthline.cling.transport.RouterImpl
org.fourthline.cling.transport.spi.MulticastReceiver INFOS : Creating wildcard socket (for receiving multicast datagrams) on port: 1900
org.fourthline.cling.transport.Router GRAVE : Unable to initialize network router: org.fourthline.cling.transport.spi.InitializationException: Could not initialize MulticastReceiverImpl: java.net.BindException: Address already in use
org.fourthline.cling.transport.Router GRAVE : Cause: org.fourthline.cling.transport.spi.InitializationException: Could not initialize MulticastReceiverImpl: java.net.BindException: Address already in use
org.fourthline.cling.UpnpServiceImpl INFOS : <<< UPnP service started successfully

It appears that the port 1900 is officially used by "Back to my mac" on mac OS. But if I make a netstat ou a lsof, no port is opened.

I have also tried to open the upnp service as next, with another port, but a got the same log telling me that the port 1900 is already in use :
upnpService = new UpnpServiceImpl(new DefaultUpnpServiceConfiguration(1902));

Is there some who can help in this situation ?

Thanks in advance,
Jason.

@auxor
Copy link

auxor commented Apr 18, 2018

Dlna use SSDP to discovery service. And Cling need to listen on 1900.

https://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol
SSDP is a text-based protocol based on HTTPU. It uses UDP as the underlying transport protocol. Services are announced by the hosting system with multicast addressing to a specifically designated IP multicast address at UDP port number 1900.

@JasonMahdjoub
Copy link
Author

So I have overrited functions of class DefaultUpnpServiceConfiguration, in order to open another port than 1900. Than my tests for discovering local routers work.

@auxor
Copy link

auxor commented Apr 20, 2018

@JazZ51,

The port you overrided in DefaultUpnpServiceConfiguration is used for http server, not for ssdp.

public StreamServer createStreamServer(NetworkAddressFactory networkAddressFactory) {
    return new StreamServerImpl(
            new StreamServerConfigurationImpl(
                    networkAddressFactory.getStreamListenPort()
            )
    );
}

@JasonMahdjoub
Copy link
Author

Thank you. I am not expert with Cling, but the port I overrided enabled me to make UPNP IGD working into macOS. Ohterwise, macOS refuse binding port 1900 that one service of cling try to open. And then, Cling seems not being able to continue to open UPNP IGD service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants