Clients using the NMS library sometimes hijacks (binds) to the port that 
ActiveMQ is listening to
-------------------------------------------------------------------------------------------------

                 Key: AMQNET-350
                 URL: https://issues.apache.org/jira/browse/AMQNET-350
             Project: ActiveMQ .Net
          Issue Type: Bug
    Affects Versions: 1.5.1, 1.5.0, 1.5.2
            Reporter: Frank Gynnild
            Assignee: Jim Gomes


If we stop ActiveMQ service first, we've sometimes seen that various clients 
(using the NMS library) binds to the same port as ActiveMQ uses for listening 
(61616).
This causes the ActiveMQ service to fail to start since its listening port is 
occupied.

Doing a "netstat -a -b" we can see the problem:
---
TCP [fe80::c591:4e66:8992:debb%11]:61616 Gelado:61616 ESTABLISHED
TestClient.exe]
---

When trying to start ActiveMQ we get this:
---
2011-11-16 10:27:38,223 | ERROR | Failed to start ActiveMQ JMS Message Broker. 
Reason: java.io.IOException: Transport Connector could not be registered in 
JMX: Failed to bind to server socket: 
tcp://0.0.0.0:61616?keepAlive=true&wireFormat.tightEncodingEnabled=false&wireFormat.cacheEnabled=false&wireFormat.maxInactivityDuration=300000
 due to: java.net.SocketException: Unrecognized Windows Sockets error: 0: 
JVM_Bind | org.apache.activemq.broker.BrokerService | main
java.io.IOException: Transport Connector could not be registered in JMX: Failed 
to bind to server socket: 
tcp://0.0.0.0:61616?keepAlive=true&wireFormat.tightEncodingEnabled=false&wireFormat.cacheEnabled=false&wireFormat.maxInactivityDuration=300000
 due to: java.net.SocketException: Unrecognized Windows Sockets error: 0: 
JVM_Bind
at 
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
at 
org.apache.activemq.broker.BrokerService.registerConnectorMBean(BrokerService.java:1678)
at 
org.apache.activemq.broker.BrokerService.startTransportConnector(BrokerService.java:2166)
at 
org.apache.activemq.broker.BrokerService.startAllConnectors(BrokerService.java:2082)
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:516)
---

When exiting the client process, the ActiveMQ service is able to start up again.

I had a look at the source code, and I think the bug is inside the 
TcpTransportFactory.cs:
{code}
if(!String.IsNullOrEmpty(location.AbsolutePath) && 
!location.AbsolutePath.Equals("/"))
                        {
                                int index = location.AbsolutePath.IndexOf(':');
                                try
                                {
                                        localPort = 
Int16.Parse(location.AbsolutePath.Substring(index + 1));                        
            
                                        localAddress = 
location.AbsolutePath.Substring(1, index - 1);
                                        Tracer.DebugFormat("Binding Socket to 
{0} on port: {1}", localAddress, localPort);
                                }
                                catch
                                {
                        Tracer.Warn("Invalid Port value on URI for local bind 
option, ignoring.");
                                }
                        }

{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to