natronq / openshift-activemq

ActiveMQ on OpenShift
Apache License 2.0
5 stars 14 forks source link

Can't connect to ActiveMQ server deployed in Openshift from my local laptop by running the included code example: examples\openwire\java #2

Open t873529 opened 5 years ago

t873529 commented 5 years ago

Hey,

By using the project, I am able to deploy / run ActiveMQ server. I see openshift-activemq application shown in Openshift web console / Overview. I can see pod's log, added below. Further, I can visit the activeMQ server admin web console in browser https://activemq-wfm-pace.paas-app-east-np.tsl.telus.com/admin/index.jsp. in the admin web console, I add a topic event. So far I am very happy. it is almost equal experience compare to deploying and running a fresh unzipped server instance at localhost.

But when I run the included client example: examples\openwire\java, I get Connection refused error. I tried different user/password pairs: admin/password, system/manager, admin/admin, no one working. In contrast, the same client example app, when I switch to target to the server running at localhost, it works with any given user/password and even without user/password,

I tried to go to my laptop Windows 10, firewall, outbound port, open 61616. no help.

Any idea what I am wrong or missing? Should I

Thanks, Chen Wang

log to run client example:


C:\d_download\Apache-activemq\apache-activemq-5.15.2-bin\apache-activemq-5.15.2\examples\openwire\java>setAppEnv_openshift.bat

C:\d_download\Apache-activemq\apache-activemq-5.15.2-bin\apache-activemq-5.15.2\examples\openwire\java>set ACTIVEMQ_HOST=activemq-wfm-pace.paas-app-east-np.tsl.telus.com

C:\d_download\Apache-activemq\apache-activemq-5.15.2-bin\apache-activemq-5.15.2\examples\openwire\java>set ACTIVEMQ_PORT=61616

C:\d_download\Apache-activemq\apache-activemq-5.15.2-bin\apache-activemq-5.15.2\examples\openwire\java>set ACTIVEMQ_USER=system

C:\d_download\Apache-activemq\apache-activemq-5.15.2-bin\apache-activemq-5.15.2\examples\openwire\java>set ACTIVEMQ_PASSWORD=manager C:\d_download\Apache-activemq\apache-activemq-5.15.2-bin\apache-activemq-5.15.2\examples\openwire\java>java -cp target/openwire-example-0.1-SNAPSHOT.jar example.Listener Exception in thread "main" javax.jms.JMSException: Could not connect to broker URL: tcp://activemq-wfm-pace.paas-app-east-np.tsl.telus.com:61616. Reason: java.net.ConnectException: Connection refused: connect at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36) at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:374) at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:252) at example.Listener.main(Listener.java:36) Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.activemq.transport.tcp.TcpTransport.connect(TcpTransport.java:525) at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:488) at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:55) at org.apache.activemq.transport.AbstractInactivityMonitor.start(AbstractInactivityMonitor.java:169) at org.apache.activemq.transport.InactivityMonitor.start(InactivityMonitor.java:52) at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64) at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:72) at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64) at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64) at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:354) ... 2 more

AvtiveMQ server log displayed in Openshift Web Console:

debug

--   | Run as uid=1001090000 gid=0(root) groups=0(root),1001090000   | lrwxrwxrwx. 1 root root 27 Jul 17 20:51 /opt/activemq -> /opt/apache-activemq-5.15.2   | lrwxrwxrwx. 1 root root 27 Jul 17 20:51 /opt/activemq -> /opt/apache-activemq-5.15.2   | total 80   | -rw-rw-rw-. 1 root root 5911 Oct 17 2017 activemq.xml   | -rw-rw-rw-. 1 root root 592 Oct 17 2017 broker-localhost.cert   | -rw-rw-rw-. 1 root root 1370 Oct 17 2017 broker.ks   | -rw-rw-rw-. 1 root root 665 Oct 17 2017 broker.ts   | -rw-rw-rw-. 1 root root 1357 Oct 17 2017 client.ks   | -rw-rw-rw-. 1 root root 665 Oct 17 2017 client.ts   | -rw-rw-rw-. 1 root root 1172 Oct 17 2017 credentials-enc.properties   | -rw-rw-rw-. 1 root root 1121 Oct 17 2017 credentials.properties   | -rw-rw-rw-. 1 root root 962 Oct 17 2017 groups.properties   | -rw-rw-rw-. 1 root root 1011 Oct 17 2017 java.security   | -rw-rw-rw-. 1 root root 1087 Oct 17 2017 jetty-realm.properties   | -rw-rw-rw-. 1 root root 7795 Oct 17 2017 jetty.xml   | -rw-rw-rw-. 1 root root 965 Oct 17 2017 jmx.access   | -rw-rw-rw-. 1 root root 964 Oct 17 2017 jmx.password   | -rw-rw-rw-. 1 root root 3071 Oct 17 2017 log4j.properties   | -rw-rw-rw-. 1 root root 1207 Oct 17 2017 logging.properties   | -rw-rw-rw-. 1 root root 1016 Oct 17 2017 login.config   | -rw-rw-rw-. 1 root root 961 Oct 17 2017 users.properties   | total 0   | -rw-rw-rw-. 1 root root 0 Oct 17 2017 activemq.log   | ###   | INFO: Loading '/opt/activemq/bin/env'   | INFO: Using java '/usr/local/openjdk-8/bin/java'   | INFO: Starting in foreground, this is just for debugging purposes (stop process by pressing CTRL+C)   | INFO: Creating pidfile /opt/activemq/data/activemq.pid   | Java Runtime: Oracle Corporation 1.8.0_212 /usr/local/openjdk-8   | Heap sizes: current=63360k free=55879k max=1013632k   | JVM args: -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/opt/activemq/conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/opt/activemq/tmp -Dactivemq.classpath=/opt/activemq/conf:/opt/activemq/../lib/: -Dactivemq.home=/opt/activemq -Dactivemq.base=/opt/activemq -Dactivemq.conf=/opt/activemq/conf -Dactivemq.data=/opt/activemq/data -agentpath:/opt/dynatrace/oneagent/agent/lib64/liboneagentloader.so   | Extensions classpath:   | [/opt/activemq/lib,/opt/activemq/lib/camel,/opt/activemq/lib/optional,/opt/activemq/lib/web,/opt/activemq/lib/extra]   | ACTIVEMQ_HOME: /opt/activemq   | ACTIVEMQ_BASE: /opt/activemq   | ACTIVEMQ_CONF: /opt/activemq/conf   | ACTIVEMQ_DATA: /opt/activemq/data   | Loading message broker from: xbean:activemq.xml   | INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@5f341870: startup date [Thu Jul 18 05:45:39 UTC 2019]; root of context hierarchy   | INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[/opt/activemq/data/kahadb]   | INFO | PListStore:[/opt/activemq/data/localhost/tmp_storage] started   | INFO | Apache ActiveMQ 5.15.2 (localhost, ID:openshift-activemq-3-vsqq2-40136-1563428741152-0:1) is starting   | INFO | Listening for connections at: tcp://openshift-activemq-3-vsqq2:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600   | INFO | Connector openwire started   | INFO | Listening for connections at: amqp://openshift-activemq-3-vsqq2:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600   | INFO | Connector amqp started   | INFO | Listening for connections at: stomp://openshift-activemq-3-vsqq2:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600   | INFO | Connector stomp started   | INFO | Listening for connections at: mqtt://openshift-activemq-3-vsqq2:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600   | INFO | Connector mqtt started   | WARN | ServletContext@o.e.j.s.ServletContextHandler@5b7a8434{/,null,STARTING} has uncovered http methods for path: /   | INFO | Listening for connections at ws://openshift-activemq-3-vsqq2:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600   | INFO | Connector ws started   | INFO | Apache ActiveMQ 5.15.2 (localhost, ID:openshift-activemq-3-vsqq2-40136-1563428741152-0:1) started   | INFO | For help or more information please see: http://activemq.apache.org   | WARN | Store limit is 102400 mb (current store usage is 0 mb). The data directory: /opt/activemq/data/kahadb only has 9880 mb of usable space. - resetting to maximum available disk space: 9880 mb   | WARN | Temporary Store limit is 51200 mb (current store usage is 0 mb). The data directory: /opt/activemq/data only has 9880 mb of usable space. - resetting to maximum available disk space: 9880 mb   | INFO | No Spring WebApplicationInitializer types detected on classpath   | INFO | ActiveMQ WebConsole available at http://0.0.0.0:8161/   | INFO | ActiveMQ Jolokia REST API available at http://0.0.0.0:8161/api/jolokia/   | INFO | Initializing Spring FrameworkServlet 'dispatcher'   | INFO | No Spring WebApplicationInitializer types detected on classpath   | INFO | jolokia-agent: Using policy access restrictor classpath:/jolokia-access.xml

sadhal commented 5 years ago

Exposed route goes to the console :8161. Try creating new route for required protocol like :61616 and use that from your client application.

t873529 commented 5 years ago

Hey Sadhal, I tried to expose the server's service/port 61616 as route in OpenShift. My local test client can't work with the route. I read Openshift Route definition, saying route is based on HTTP header. 61616/Openwire is binary over TCP. That is why client app outside Openshift env won't work with the ActiveMQ server running in OpenShift. I change to deploy the test client into Openshift and target server's Service host, the client works. Thanks for your help and sharing. Chen.

devamondos commented 4 years ago

@sadhal so just to confirm, did you only get this working within the OpenShift environment? I am having the same issue as @t873529. For example, I can not connect to it from a development application build. I need to connect over TCP on port 61616 but this does not work with OpenShift routes.

sadhal commented 4 years ago

No @devamondos I did not. Was trying to assist but it was an untested advice, sorry. Is your development application inside the same cluster or do you mean application running on your development machine? If you are running inside cluster and can use cluster DNS you should be fine without routes. If you are running on development machine and broker inside cluster you have access to you could try oc port-forward but do plan for how you will connect to broker from other environments...

cheruvu007 commented 3 years ago

Thank you Sandhal, I have tried oc port-forward and it worked fine. Appreciated your help!. Client running on local and ActiveMQ running on OPenshift, port-forward does the job.