|« Disappearing pink dots illusion||Quick guide to installing WordPress under Plesk »|
"port out of range" on activemq topicMay 21st, 2009
I recently came across a problem with ActiveMQ and Spring which took a while to find. As with all the articles on this blog, I had to figure it out myself because there weren’t any solutions on the inter-web.
The confusion was caused by the message port out of range:-1 for a JMS broker address of tcp://prd_live_sm:61616. The full error message is:
2009-05-08 11:46:21,171 INFO [uk.co.bigsoft.myapp.RsmDefaultMessageListenerContainer] - could not refresh JMS Connection for destination ‘topic://prd_live_sm’ - retrying in 5000 ms. Cause: Could not connect to broker URL: tcp://prd_live_sm:61616. Reason: java.lang.IllegalArgumentException: port out of range:-1
For completeness the Spring bean for the the broker is:
As you can see the port number is 61616 which is a valid port number. Valid port numbers range from 1 to 216-1 (65535).
The clue is in the minus one port number. Minus one is almost certainly an invalid value which is set at the start of parsing the URI. This means that the parsing part was not successful, if it was it would have correctly identified the port number as 61616. I know that the protocol part was all right so the problem must be in the host name.
I knew that underscores were illegal characters in a host names but I thought it would be all right. Sloppy windows allowed my co-worker to give all the machines in this new set up host names containing underscores. ActiveMQ was the only component that complained.
I changed the
hosts file an added an alias to all the machine names containing underscores, so
prdlivesm. I updated the ActiveMQ topic pick up address to the host name without the underscores and restarted my container. Low and behold it worked!
The internet standards state that underscores are not allowed, and yet Windows allows them. Who is right? Almost every open source implementation of everything is strict on host names, this includes, but is not limited to Squid cache and Apache HTTP. So the quick answer is that if you want system interoperability then don’t put underscores in your host names. However, if you run a Windows shop you can do what you like but don’t expect things to work very well!
Now my test works.