Search code examples
activemq-artemis

ActiveMQ Artemis over HTTP


Goal

I have a server, where all the traffic to any public IP goes through proxy. I have configured https_proxy and http_proxy. I want to connect to ActiveMQ Artemis running in cloud with public IP.

Now, when I hit a curl command to ActiveMQ Management Console I get the response, which implies that I am able to reach to the server

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <title>Hawtio</title>
  <base href='/activemq/'>
  <link id="favicon" rel="icon" type="image/x-icon" href="img/favicon.ico?v=1">

  <link rel="stylesheet" href="css/lib-6a1e4ce9ea.css"/>

  <link rel="stylesheet" href="css/app-9653e9917c.css"/>

  <!-- branding -->
  <link id="branding" rel="stylesheet" type="text/css" href="" />

  <script src="js/lib-e53c220218.js" defer></script>

  <script src="js/app-fafe513f4b.js" defer></script>
</head>


<body>
  <hawtio-login></hawtio-login>
</body>

</html>

If I do a telnet to the ActiveMQ Server, it times out.

telnet <ip> 61616

broker.xml

<acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true;supportAdvisory=false;suppressInternalManagementObjects=false</acceptor>

What I tried?

I tried to configure Netty over HTTP Protocol, but still it times out

artemis producer --url "tcp://<ip>:61616?httpEnabled=true" --user "artemis" --password "artemis" --message-count 1

I get this error:

Exception in thread "main" javax.jms.JMSException: Failed to create session factory
    at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:915)
    at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:314)
    at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:309)
    at org.apache.activemq.artemis.cli.commands.messages.Producer.execute(Producer.java:142)
    at org.apache.activemq.artemis.cli.Artemis.internalExecute(Artemis.java:219)
    at org.apache.activemq.artemis.cli.Artemis.execute(Artemis.java:165)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.apache.activemq.artemis.boot.Artemis.execute(Artemis.java:157)
    at org.apache.activemq.artemis.boot.Artemis.main(Artemis.java:64)
Caused by: ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ219007: Cannot connect to server(s). Tried with all available servers.]
    at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:735)
    at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:913)
    ... 11 more

Solution

  • HTTP is really not a good protocol for messaging since it was designed for a completely different use-case. If there's any chance you can avoid using it you should try. It's really meant for environments where you have absolutely no choice. In any case, I don't think the client or the broker can really do anything here since the issue appears to be in the network somewhere.