Cannot use JMS over HTTPS port in WildFly
sam.jones Apr 21, 2014 12:43 PMI want to post this question to get a definitive, bare minimum configuration that is supposed to work. I have been trying to get JMS to work using the https port, but I'm having no luck. I came across these threads: WildFly CR1 HornetQ over https: HQ119013: Timed out waiting to receive cluster topology and Re: Problem connecting to jms topic when using https. I also see that there is an outstanding bug that is related to my issue: [HORNETQ-1317] Error connecting with http-upgrade mechanism against https port on WildFly - JBoss Issue Tracker. However, I don't see the exact same error message. SSL is working in the browser when I go to my application's web root.
This is what I have added to the configuration.
<server xmlns="urn:jboss:domain:2.0">
...
<management>
<security-realms>
...
<security-realm name="UndertowRealm">
<server-identities>
<ssl>
<keystore path="server.keystore" relative-to="jboss.server.config.dir" keystore-password="changeit" alias="server" key-password="changeit"/>
</ssl>
</server-identities>
</security-realm>
</security-realms>
...
</management>
<profile>
...
<subsystem xmlns="urn:jboss:domain:messaging:2.0">
<hornetq-server>
...
<connectors>
...
<http-connector name="https-connector" socket-binding="https">
<param key="http-upgrade-endpoint" value="https-acceptor"/>
<param key="ssl-enabled" value="true"/>
</http-connector>
</connectors>
<acceptors>
...
<http-acceptor name="https-acceptor" http-listener="https"/>
</acceptors>
<jms-connection-factories>
...
<connection-factory name="SecureRemoteConnectionFactory">
<connectors>
<connector-ref connector-name="https-connector"/>
</connectors>
<entries>
<entry name="java:/SecureRemoteConnectionFactory"/>
<entry name="java:jboss/exported/jms/SecureRemoteConnectionFactory"/>
</entries>
<connection-ttl>-1</connection-ttl>
<reconnect-attempts>-1</reconnect-attempts>
</connection-factory>
...
</jms-connection-factories>
...
</hornetq-server>
</subsystem>
...
<subsystem xmlns="urn:jboss:domain:undertow:1.0">
...
<server name="default-server">
...
<https-listener name="https" socket-binding="https" security-realm="UndertowRealm"/>
...
</server>
...
</subsystem>
...
</profile>
...
</server>
My client-side code looks like the following:
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, "http-remoting://localhost:8443");
env.put(Context.SECURITY_PRINCIPAL, "test");
env.put(Context.SECURITY_CREDENTIALS, "****");
InitialContext ic = new InitialContext(env);
TopicConnectionFactory factory = (TopicConnectionFactory) ic.lookup("jms/SecureRemoteConnectionFactory");
TopicConnection connection = cf.createTopicConnection("test", "****");
The program's command-line arguments include the following:
-Djavax.net.ssl.trustStore=C:\Path\to\truststore.jks
-Djavax.net.ssl.trustStorePassword=****
The client throws an error on the lookup line:
javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [http-remoting://localhost:8443 (java.io.EOFException: XNIO000812: Connection closed unexpectedly)]
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)
at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)
at javax.naming.InitialContext.lookup(InitialContext.java:411)