Uploaded image for project: 'ActiveMQ Artemis'
  1. ActiveMQ Artemis
  2. ARTEMIS-4654

Misleading error message while connecting to host with underscore

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Information Provided
    • 2.31.0
    • None
    • Configuration
    • None

    Description

      Underscore in hostname produces unexpected error message. See details below.

      It's problematic since

      1. error message is misleading
      2. hostname with underscore is valid for certain setups. I.e in Docker compose / swarm environments.
      3. underscore in hostname works for different other client libraries. Tested with Postgres, InfluxDB, Redis 

      Code

      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://local_host:61616");
      factory.createConnection();
      

      produces output

      WARN  [org.apa.act.art.cor.client] (main) AMQ212007: connector.create or connectorFactory.createConnector should never throw an exception, implementation is badly behaved, but we will deal with it anyway.: java.lang.IllegalArgumentException: port out of range:-1
          at java.base/java.net.InetSocketAddress.checkPort(InetSocketAddress.java:152)
          at java.base/java.net.InetSocketAddress.<init>(InetSocketAddress.java:233)
          at org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector.createConnection(NettyConnector.java:874)
          at org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector.createConnection(NettyConnector.java:866)
          at org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector.createConnection(NettyConnector.java:848)
          at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.openTransportConnection(ClientSessionFactoryImpl.java:1212)
          at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.createTransportConnection(ClientSessionFactoryImpl.java:1333)
          at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.createTransportConnection(ClientSessionFactoryImpl.java:1253)
          at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.establishNewConnection(ClientSessionFactoryImpl.java:1496)
          at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.getConnection(ClientSessionFactoryImpl.java:1074)
          at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.getConnectionWithRetry(ClientSessionFactoryImpl.java:959)
          at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.connect(ClientSessionFactoryImpl.java:279)
          at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.connect(ClientSessionFactoryImpl.java:295)
          at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:709)
          at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:865)
          at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:284)
          at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:279)
          ...
      

      while code 

      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://local-host:61616");
      factory.createConnection();
      

      produces output

      ERROR [org.apa.act.art.cor.client] (main) AMQ214016: Failed to create netty connection: java.net.UnknownHostException: local-host
          at java.base/java.net.InetAddress$CachedAddresses.get(InetAddress.java:801)
          at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1509)
          at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1367)
          at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1301)
          at java.base/java.net.InetAddress.getByName(InetAddress.java:1251)
          at io.netty.util.internal.SocketUtils$8.run(SocketUtils.java:156)
          at io.netty.util.internal.SocketUtils$8.run(SocketUtils.java:153)
          at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
          at io.netty.util.internal.SocketUtils.addressByName(SocketUtils.java:153)
          at io.netty.resolver.DefaultNameResolver.doResolve(DefaultNameResolver.java:41)
          at io.netty.resolver.SimpleNameResolver.resolve(SimpleNameResolver.java:61)
          at io.netty.resolver.SimpleNameResolver.resolve(SimpleNameResolver.java:53)
          at io.netty.resolver.InetSocketAddressResolver.doResolve(InetSocketAddressResolver.java:55)
          at io.netty.resolver.InetSocketAddressResolver.doResolve(InetSocketAddressResolver.java:31)
          at io.netty.resolver.AbstractAddressResolver.resolve(AbstractAddressResolver.java:106)
          at io.netty.bootstrap.Bootstrap.doResolveAndConnect0(Bootstrap.java:206)
          at io.netty.bootstrap.Bootstrap.access$000(Bootstrap.java:46)
          at io.netty.bootstrap.Bootstrap$1.operationComplete(Bootstrap.java:180)
          at io.netty.bootstrap.Bootstrap$1.operationComplete(Bootstrap.java:166)
          at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:590)
          at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:557)
          at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:492)
          at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:636)
          at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:625)
          at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:105)
          at io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:84)
          at io.netty.channel.AbstractChannel$AbstractUnsafe.safeSetSuccess(AbstractChannel.java:990)
          at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:516)
          at io.netty.channel.AbstractChannel$AbstractUnsafe.access$200(AbstractChannel.java:429)
          at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:486)
          at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
          at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
          at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
          at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:406)
          at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
          at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
          at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            laurikimmel Lauri Kimmel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: