Search code examples
androidcordovahybridkaazing

Kaazing JMS Client Fails to connect


I'm able to connect my hybrid android app with Kaazing using the following lines:

 var jmsConnectionFactory;
 jmsConnectionFactory = new JmsConnectionFactory("ws://10.0.2.2:8888/jms");
 var connectionFuture = jmsConnectionFactory.createConnection(null, null, function () {/*something is done here*/}

lines of the gateway-config.xml are:

<service>
<name>JMS Service</name>
<description>JMS Service</description>   
 <accept>ws://10.0.2.2:8888/jms</accept>
<type>jms</type>

<properties>
  <connection.factory.name>GenericConnectionFactory</connection.factory.name>
  <context.lookup.topic.format>%s</context.lookup.topic.format>
  <context.lookup.queue.format>%s</context.lookup.queue.format>

  <env.java.naming.factory.initial>com.tibco.tibjms.naming.TibjmsInitialContextFactory</env.java.naming.factory.initial>
  <env.java.naming.provider.url>tcp://localhost:7222</env.java.naming.provider.url>
  <destination.strategy>session</destination.strategy>
</properties>
<accept-options>
  <ws.bind>localhost:8888</ws.bind>
</accept-options>
<realm-name>demo</realm-name>
<cross-site-constraint>
  <allow-origin>*</allow-origin>      
</cross-site-constraint>

This is the error

ConnectionFailedException : WebSocket connection failed"

The worst part is that it was working fine, and I was able to connect but now it is not working.

What I did was upgraded my nodejs installed cordova to upgrade it. Now I have brought back every thing but it doesn't work.


Solution

  • In what I say below, KAAZING_GATEWAY_HOME represents the directory in which you installed the Kaazing JMS Gateway.

    There are several moving parts - the client, the Kaazing JMS Gateway, and the EMS back-end. The problem could be the Kaazing JMS Gateway connecting to EMS on the back end, or there could be an issue with the client trying to connect to the Kaazing JMS Gateway. There is not much detail yet. In order for us to troubleshoot, one way to provide more detail is to make the logging on the Kaazing JMS Gateway more verbose.

    The log is by default written to KAAZING_GATEWAY_HOME/log/. There are several there but the main log is error.log. Its default LOG4J configuration is in KAAZING_GATEWAY_HOME/conf/log4j-config.xml. You can get more diagnostics for the connection issues on both ends by replacing the contents of that file with the following (you can make a backup copy to restore the default log configuration later):

    <?xml version="1.0" encoding="UTF-8" ?>
    
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
        <appender name="ErrorFile" class="org.apache.log4j.RollingFileAppender">
            <param name="File" value="${GATEWAY_LOG_DIRECTORY}/error.log"/>
            <param name="Append" value="false"/>
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="%d [%t] %-5p %m%n"/>
            </layout>
        </appender>
    
        <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="%d [%t] %-5p %m%n"/>
            </layout>
        </appender>
    
        <logger name="transport">
            <level value="trace"/>
        </logger>
    
        <logger name="com.kaazing.gateway.jms">
            <level value="trace"/>
        </logger>
    
        <logger name= "service.stomp.jms">
            <level value="trace"/>
        </logger>
    
        <logger name= "service.jms">
            <level value="trace"/>
        </logger>
    
        <root>
            <priority value="info"/>
            <appender-ref ref="ErrorFile"/>
            <appender-ref ref="STDOUT"/>
        </root>
    
    </log4j:configuration>
    

    Once you have copied that in place, try connecting again. If you see no logging in the gateway for the connection attempts from your client, it means there is an issue in the client code or configuration, between the client and the gateway, or on the client machine itself. Otherwise, please share the results of updating this. The results should be time-stamped so you can tell which log entries correspond to your attempts to connect.

    You can share your logs here, or directly to me at the address below.

    Please keep us posted. Best regards, Dan Smith, Kaazing Global Support daniel.smith@kaazing.com