6 Replies Latest reply on Oct 31, 2012 8:11 PM by jacob1111

    Hotrod remote server exception

    jacob1111 Newbie

      Hi,

       

      I am trying to use Infinispan remote cache on the remote server. I am using Java application

      to connect to the server and store objects in the memory.

       

      When I ran this application for the local hotrod server using loopback address

      (127.0.0.1) it works. However, when I try to use it for remote server it fails.

      Here is the code snippet:

       

      import org.infinispan.client.hotrod.RemoteCache;

      import org.infinispan.client.hotrod.RemoteCacheManager;

       

      public class HotRodRemoteClient

      {

        public void start() 

        {

          RemoteCacheManager manager = new RemoteCacheManager("10.100.9.28");

          RemoteCache<Integer, Ticket> cache = manager.getCache();

           ............................................

       

      Here is the exception:

       

      ISPN004017: Could not fetch transport

      org.infinispan.client.hotrod.exceptions.TransportException:: Could not connect to server: /10.100.9.28:11222

          at org.infinispan.client.hotrod.impl.transport.tcp.TcpTransport.<init>(TcpTransport.java:90)

          at org.infinispan.client.hotrod.impl.transport.tcp.TransportObjectFactory.makeObject(TransportObjectFactory.java:57)

          at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1220)

          at org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory.borrowTransportFromPool(TcpTransportFactory.java:254)

          at org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory.getTransport(TcpTransportFactory.java:145)

          at org.infinispan.client.hotrod.impl.operations.FaultTolerantPingOperation.getTransport(FaultTolerantPingOperation.java:44)

          at org.infinispan.client.hotrod.impl.operations.RetryOnFailureOperation.execute(RetryOnFailureOperation.java:67)

          at org.infinispan.client.hotrod.impl.RemoteCacheImpl.ping(RemoteCacheImpl.java:432)

          at org.infinispan.client.hotrod.RemoteCacheManager.ping(RemoteCacheManager.java:538)

          at org.infinispan.client.hotrod.RemoteCacheManager.createRemoteCache(RemoteCacheManager.java:520)

          at org.infinispan.client.hotrod.RemoteCacheManager.getCache(RemoteCacheManager.java:452)

          at org.infinispan.client.hotrod.RemoteCacheManager.getCache(RemoteCacheManager.java:447)

          at com.packtpub.infinispan.chapter2.HotRodRemoteClient.start(HotRodRemoteClient.java:17)

          at com.packtpub.infinispan.chapter2.HotRodRemoteClient.main(HotRodRemoteClient.java:65)

      Caused by: java.net.ConnectException: Connection refused

          at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)

          at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:599)

          at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:100)

          at org.infinispan.client.hotrod.impl.transport.tcp.TcpTransport.<init>(TcpTransport.java:81)

          ... 13 more

       

      I can ping the server 10.100.9.28:

      shell> ping 10.100.9.28

      PING 10.100.9.28 (10.100.9.28): 56 data bytes

      64 bytes from 10.100.9.28: icmp_seq=0 ttl=64 time=0.261 ms

      64 bytes from 10.100.9.28: icmp_seq=1 ttl=64 time=0.184 ms

      64 bytes from 10.100.9.28: icmp_seq=2 ttl=64 time=0.290 ms

      64 bytes from 10.100.9.28: icmp_seq=3 ttl=64 time=0.285 ms

       

      I use Infinispan 5.1.6, Maven 3.04, JDK6.33.

      My hotrod server runs on Centos 5.5, but Java application is on Mac 10.7

       

      Firewalls on both machines are disabled.

       

      I suspect this is configuration problem. What should I change to make it to work?

       

      Thank you,

       

      Jacob Nikom

        • 1. Re: Hotrod remote server exception
          Mircea Markus Master

          is the server started on 11222? can you telnet there?

          1 of 1 people found this helpful
          • 2. Re: Hotrod remote server exception
            jacob1111 Newbie

            Hi Mircea,

             

            Thank you very much for your response.

             

            I have serious difficulties trying to get data using HotRod server

            that runs on the remote node - I mean on the machine that is

            different than the HotRod client runs.

             

            This is very imprtant case for me because I am trying to emulate

            near cache use case.

             

            The client program is very simple. When I run it on the local node

            (the same as HotRod server) it works flawlessly.

            If I ran HotRod server in on remote node the client cannot get the server.

             

            In both cases HotRod servers on local and remote nodes work very well.

            I don't have any problems with them.

             

            I use Infinispan default settings, so it is likey I use jgroup_udp.xml

            I did not change that file, but I had to change a little bit HotRod startup

            script to get it to work.

             

            Now it looks like that:

            ===================================================

            shell> more startServer.sh.next

            #!/bin/bash

             

            source "`dirname "$0"`/functions.sh"

             

            CLIENT_HOME=/home/jnikom/Kiva/Downloads/Java/Infinispan/dev/HotRod_01

             

            add_classpath "${ISPN_HOME}"/*.jar

            add_classpath "${ISPN_HOME}/lib"

            add_classpath "${ISPN_HOME}/modules/memcached"

            add_classpath "${ISPN_HOME}/modules/hotrod"

            add_classpath "${ISPN_HOME}/modules/websocket"

             

            add_jvm_args $JVM_PARAMS

            add_jvm_args '-Djava.net.preferIPv4Stack=true'

            add_jvm_args '-Djgroups.bind_addr=10.100.9.28'

            add_jvm_args '-Djgroups.udp.mcast_addr=228.10.10.10'

            add_jvm_args '-Djgroups.udp.mcast_port=45588'

            add_jvm_args '-Djgroups.udp.ip_ttl=5'

            add_jvm_args '-Xms512m'

            add_jvm_args '-Xmx3g'

             

            # RHQ monitoring options

            add_jvm_args '-Dcom.sun.management.jmxremote.ssl=false'

            add_jvm_args '-Dcom.sun.management.jmxremote.authenticate=false'

            add_jvm_args -Dcom.sun.management.jmxremote.port=$(find_tcp_port)

             

            # Workaround for JDK6 NPE: http://bugs.sun.com/view_bug.do?bug_id=6427854

            add_jvm_args '-Dsun.nio.ch.bugLevel=""'

             

            # Sample JPDA settings for remote socket debugging

            #add_jvm_args "-Xrunjdwp:transport=dt_socket,address=8686,server=y,suspend=n"

             

            # LOG4J configuration

            LOG4J_CONFIG=file:///${CLIENT_HOME}/log4j.properties

             

            add_program_args "$@"

             

            start org.infinispan.server.core.Main

            ===========================================

             

            Here is the snippet of the Java code:

            ===========================================

             

            import java.util.Set;

            import java.util.Map;

            import java.util.Iterator;

             

            import org.infinispan.client.hotrod.RemoteCache;

            import org.infinispan.client.hotrod.RemoteCacheManager;

             

            public class HotRodRemoteClient

            {

              public void start() 

              {

                RemoteCacheManager rm = new RemoteCacheManager("127.0.0.1");

            //  RemoteCacheManager rm = new RemoteCacheManager("10.100.9.9");

               

                RemoteCache<Integer, Ticket> rc = rm.getCache("clusteredCache");

             

                String command = ""; // Line read from standard in

                int ticketid = 1;

            ....................................

            ...................

            ====================================================

             

            Again, HotRod servers on both nodes run very well.

             

            I use Intel Zeon 2.0 GHz, 2 CPU 8 core hardware,

            CentOS 5.5, JDK 1.6.0_31

            Infinispan 5.1.6

             

            My another node is a virtual system. I run CentOS 5.5

            on Mac i7 using JDK 1.6.0_31 and Infinispan 5.1.6.

             

            I am able to ssh over there, ping, telnet, etc.

            Moreover, in embeeded mode I am able to replicate (Infinispan)

            between those two machines.

             

            If I am able to do that,  why I cannot reach the remote HorRod cerver

            from my client?

             

            Thanks again for your help.

             

            Best regards,

             

            Jacob Nikom

            • 3. Re: Hotrod remote server exception
              jacob1111 Newbie

              Hi Mircea,

               

              I also wanted to add Infinispan configuration file for this problem:

              ==============================================================

              <infinispan>

                  <global>

                      <transport nodeName="Infinispan-Node1" clusterName="infinispan-cluster" >

                      </transport>

                  

                  </global>

                  <namedCache name="clusteredCache">

                 

                      <clustering mode="replication">

                  

                           <stateTransfer

                              chunkSize="0"

                              fetchInMemoryState="false"

                              timeout="240000">

                           </stateTransfer>

                 

                           <sync replTimeout="20000"/>

                  

                        </clustering>

                 

                  </namedCache>

               

              </infinispan>

              ===============================================

              • 4. Re: Hotrod remote server exception
                Mircea Markus Master

                I'm sorry I cannot be of more help Jacob, but this looks like a network releated issue to me. What HRClient does is simply:

                         socketChannel = SocketChannel.open();

                         socket = socketChannel.socket();

                         socket.connect(serverAddress, transportFactory.getConnectTimeout());

                Do you happen to hav multiple network interfaces? Might be that the client connects to the wrong one..

                • 6. Re: Hotrod remote server exception
                  jacob1111 Newbie

                  Hi Galder,

                   

                  Thank you for your reply.

                   

                  Unfortunately, I could not find your comments about this case.

                  Did you answer my question?

                   

                  Regards,

                   

                  Jacob Nikom