Home Help Center

IceGrid: Ice.ConnectionRefusedException

mefostermefoster Member Mary Ellen FosterOrganization: Heriot-Watt University, EdinburghProject: ECHOES learning environment ✭✭✭
I've just started learning how to use ICE -- very cool tool! I'm obviously having a fundamental misunderstanding of how IceGrid servers are supposed to work, because I just can't get icegridadmin to start anything. I'll try to include the relevant code and output messages; I'm sure this is obvious, but I just don't understand what's happening here. Thanks for any tips!

HelloServer.java
public class HelloServer extends Ice.Application {

    public int run( String[] args ) {
        Ice.ObjectAdapter oa = communicator().createObjectAdapter( "HelloAdapter" );
        HelloI helloI = new HelloI();
        oa.add( helloI, Ice.Util.stringToIdentity( "HelloServer" ));
        oa.activate();
        communicator().waitForShutdown();
        return 0;
    }

    public static void main( String[] args ) {
        System.exit( new HelloServer().main( "HelloServer", args ));
    }
}

Ice config file:
# Registry properties
IceGrid.Registry.Client.Endpoints=tcp -p 10000
IceGrid.Registry.Server.Endpoints=tcp
IceGrid.Registry.Admin.Endpoints=tcp
IceGrid.Registry.Internal.Endpoints=tcp
IceGrid.Registry.Data=/home/mef/workspace/icegrid/registry

# Node properties
IceGrid.Node.Endpoints=tcp
IceGrid.Node.Name=Node1
IceGrid.Node.Data=/home/mef/workspace/icegrid/node
IceGrid.Node.CollocateRegistry=1
Ice.Default.Locator=IceGrid/Locator:tcp -p 10000

IceGrid .xml config file
<icegrid>
    <application name="Hello">
        <node name="Node1">
            <server id="HelloServer"
                exe="/home/mef/workspace/icegrid/bin/run-hello.sh"
                activation="on-demand">
                <adapter name="HelloAdapter"
                    id="HelloAdapter"
                    register-process="true"
                    endpoints="tcp"/>
                <property name="Ice.Trace.Network" value="2"/>
                <property name="Ice.Trace.Protocol" value="1"/>
            </server>
        </node>
    </application>
</icegrid>

Here's what happens when I try to start the above server through icegridadmin ("server start HelloServer"):
[ HelloServer: Network: attempting to bind to tcp socket 129.215.164.80:0 ]
[ HelloServer: Network: accepting tcp connections at 129.215.164.80:55827 ]
[ HelloServer: Network: attempting to bind to tcp socket 127.0.0.1:0 ]
[ HelloServer: Network: accepting tcp connections at 127.0.0.1:40045 ]
[ HelloServer: Network: trying to establish tcp connection to 127.0.0.1:0 ]
[ HelloServer: Network: trying to establish tcp connection to 127.0.0.1:0 ]
HelloServer: Ice.ConnectionRefusedException
    error = 0
Ice.ConnectionRefusedException
    error = 0
        at IceInternal.Network.doConnect(Network.java:278)
        at IceInternal.TcpConnector.connect(TcpConnector.java:25)
        at IceInternal.OutgoingConnectionFactory.create(OutgoingConnectionFactory.java:308)
        at IceInternal.DirectReference.getConnection(DirectReference.java:178)
        at Ice._ObjectDelM.setup(_ObjectDelM.java:257)
        at Ice.ObjectPrxHelperBase.__getDelegate(ObjectPrxHelperBase.java:700)
        at Ice.LocatorPrxHelper.getRegistry(LocatorPrxHelper.java:95)
        at Ice.LocatorPrxHelper.getRegistry(LocatorPrxHelper.java:83)
        at IceInternal.LocatorInfo.getLocatorRegistry(LocatorInfo.java:57)
        at Ice.ObjectAdapterI.activate(ObjectAdapterI.java:82)
        at mef.HelloServer.run(HelloServer.java:10)
        at Ice.Application.main(Application.java:71)
        at Ice.Application.main(Application.java:36)
        at Ice.Application.main(Application.java:30)
        at mef.HelloServer.main(HelloServer.java:16)
Caused by: java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:525)
        at IceInternal.Network.doConnect(Network.java:253)
        ... 14 more
[ HelloServer: Network: stopping to accept tcp connections at 129.215.164.80:55827 ]
[ HelloServer: Network: stopping to accept tcp connections at 127.0.0.1:40045 ]

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Mary,

    For some reasons the server is trying to connect to the host/port 127.0.0.1:0, the port number looks wrong. I can't see anything wrong in your configuration file... Did you try to run the demo/IceGrid/simple to see if you were getting the same issue?

    Also, which Ice version, JDK and operating system do you use?

    Cheers,
    Benoit.
  • mefostermefoster Member Mary Ellen FosterOrganization: Heriot-Watt University, EdinburghProject: ECHOES learning environment ✭✭✭
    Argh ... of course, the demo server works fine. I should have tried that previously, rather than flailing around with my own stuff. I think I'll try just basing my implementation on that, rather than trying to figure out what was wrong with my attempt.

    For what it's worth, I'm using Sun Java 1.5.0_07 on Fedora Core 5 (i686), with Ice 3.0.1.

    MEF
  • mefostermefoster Member Mary Ellen FosterOrganization: Heriot-Watt University, EdinburghProject: ECHOES learning environment ✭✭✭
    Problem solved: Don't use shell scripts to run Java

    Okay, I think I've tracked it down. The server I'm running is a Java program that requires a fairly extensive CLASSPATH, so I had written a short shell script to set the path and then exec java with the appropriate arguments, and then I used that shell script in the server definition in the IceGrid config file.

    I just changed my config file to use exe="java" with an appropriate <option>, setting the CLASSPATH separately, and it appears to be working fine now. I suspect it's something to do with environment settings somewhere ... does IceGrid do something magic with environment variables or something like that?

    Boy, was that annoying to track down. :p

    MEF
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    IceGrid doesn't do anything magic. It just sets the environment variables specified in the descriptor, it won't modify other environment variables.

    Cheers,
    Benoit.
  • mefostermefoster Member Mary Ellen FosterOrganization: Heriot-Watt University, EdinburghProject: ECHOES learning environment ✭✭✭
    Nonetheless, it does seem to be the shell script that's breaking it. With the same configuration and CLASSPATH, the following configuration starts up fine:
    <icegrid>
      <application name="JAST">
        <node name="Node1">
          <server id="FissionServer" activation="on-demand" exe="java">
            <option>de.tum.in.jast.fission.FissionIceServer</option>
            <adapter name="Fission" endpoints="tcp" register-process="true">
              <object identity="fission" type="::jast::Fission"/>
            </adapter>
            <property name="Identity" value="fission"/>
          </server>
        </node>
      </application>
    </icegrid>
    

    However, the following configuration dies with the ConnectionRefusedException I showed in my previous mail (I'll include run_fission2.sh below); the only difference is in what is executed.
    <icegrid>
      <application name="JAST">
        <node name="Node1">
          <server id="FissionServer" activation="on-demand"
            exe="/home/mef/workspace/fission-jast/bin/run_fission2.sh">
            <adapter name="Fission" endpoints="tcp" register-process="true">
              <object identity="fission" type="::jast::Fission"/>
            </adapter>
            <property name="Identity" value="fission"/>
          </server>
        </node>
      </application>
    </icegrid>
    

    Here is run_fission2.sh:
    #!/bin/sh
    
    java de.tum.in.jast.fission.FissionIceServer $*
    

    So, something about executing a shell script instead of executing Java directly is definitely triggering something weird in IceGrid ...

    MEF
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    I'm not sure why this isn't working. I just modified the demo/IceGrid/simple demo to do something similar and it worked. Here's the script I used:
    #!/bin/sh
    
    java Server $*
    

    I saved this script in the demo/IceGrid/simple directory with the name "javaexe". Then, I've set the executable permissions on the script and changed the application.xml descriptor to:
    <icegrid>
      <application name="Simple">
        <node name="localhost">
          <server id="SimpleServer" exe="./javaexe" activation="on-demand">
            <adapter name="Hello" endpoints="tcp" register-process="true">
              <object identity="hello" type="::Demo::Hello"/>
            </adapter>
            <property name="Identity" value="hello"/>
          </server>
        </node>
      </application>
    </icegrid>
    

    When I run the client the server is successfully started on demand. Can you perhaps try it out with the demo? If something fails, could you run the IceGrid node with the property IceGrid.Node.Trace.Activator set to 2 and post the trace here?

    Thanks,

    Benoit.
  • mefostermefoster Member Mary Ellen FosterOrganization: Heriot-Watt University, EdinburghProject: ECHOES learning environment ✭✭✭
    I tried what you suggested, and it's still doing the same thing. Here's the trace from the node, running with IceGrid.Node.Trace.Activator=2 (it doesn't look too helpful ...).

    To remind you: this is Java 1.5.0_07 on Fedora Core 5, if that affects anything.
    [ icegridnode: Server: changed server `SimpleServer1' state to `Loading' ]
    [ icegridnode: Server: changed server `SimpleServer1' state to `Inactive' ]
    [ icegridnode: Server: changed server `SimpleServer1' state to `Activating' ]
    [ icegridnode: Activator: activating server `SimpleServer1' ]
    [ icegridnode: Activator: activated server `SimpleServer1' (pid = 16092) ]
    [ icegridnode: Server: changed server `SimpleServer1' state to `WaitForActivation' ]
    Server: Ice.ConnectionRefusedException
        error = 0
    Ice.ConnectionRefusedException
        error = 0
            at IceInternal.Network.doConnect(Network.java:278)
            at IceInternal.TcpConnector.connect(TcpConnector.java:25)
            at IceInternal.OutgoingConnectionFactory.create(OutgoingConnectionFactory.java:308)
            at IceInternal.DirectReference.getConnection(DirectReference.java:178)
            at Ice._ObjectDelM.setup(_ObjectDelM.java:257)
            at Ice.ObjectPrxHelperBase.__getDelegate(ObjectPrxHelperBase.java:700)
            at Ice.LocatorPrxHelper.getRegistry(LocatorPrxHelper.java:95)
            at Ice.LocatorPrxHelper.getRegistry(LocatorPrxHelper.java:83)
            at IceInternal.LocatorInfo.getLocatorRegistry(LocatorInfo.java:57)
            at Ice.ObjectAdapterI.activate(ObjectAdapterI.java:82)
            at Server.run(Server.java:19)
            at Ice.Application.main(Application.java:71)
            at Ice.Application.main(Application.java:36)
            at Ice.Application.main(Application.java:30)
            at Server.main(Server.java:28)
    Caused by: java.net.ConnectException: Connection refused
            at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
            at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:525)
            at IceInternal.Network.doConnect(Network.java:253)
            ... 14 more
    [ icegridnode: Activator: detected termination of server `SimpleServer1'
      exit code = 1 ]
    [ icegridnode: Adapter: server `SimpleServer1' adapter `SimpleServer1.Hello' deactivated ]
    [ icegridnode: Server: changed server `SimpleServer1' state to `Inactive' ]
    

    MEF
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    I'll try to reproduce with a similar configuration. In the meantime, one of my colleague (hi Michi ;)) suggested to try to use exec in the shell script to see if it helps. That is -- you could try with the following script:
    #!/bin/sh
    exec java Server "[email protected]"
    

    Let us know if it helps!

    Cheers,
    Benoit.
  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    I would also try to run client and server with --Ice.Trace.Network=2 and --Ice.Trace.Protocol=1. That will help identify what's going wrong in the server.

    Cheers,

    Michi.
  • mefostermefoster Member Mary Ellen FosterOrganization: Heriot-Watt University, EdinburghProject: ECHOES learning environment ✭✭✭
    Using "exec" in the shell script didn't fix anything -- I think I tried that before, actually. I'll attach the output of the node with Trace.Network=2 and Trace.Protocol=1 under two modes; in both cases, I started (or tried to start) the server through icegridadmin.

    - node-shell.log: with exe="./javaexe"
    - node-java.log: with exe="java"

    This is really weird, I agree!

    MEF
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    When you use the script, the server is trying to connect to the locator with the wrong TCP/IP port:
    [ SimpleServer1: Network: trying to establish tcp connection to 127.0.0.1:0 ]
    

    It appears that the locator proxy isn't correctly set for your server. The locator proxy is passed as a command line argument to the started process (you can see the arguments passed to the process by bumping the IceGrid.Node.Trace.Activator trace to 3).

    I suspect your shell script isn't correctly passing the arguments to the Java process. That is, the locator proxy "IceGrid/Locator:tcp -p 10000" is passed as 3 different arguments (this would explain the bogus port from the trace).

    Did you try using "[email protected]" (with the quotes) instead of $* in the script? If this still doesn't work, you could add some code to the server main method to print the arguments and check if the locator proxy is correct.

    Cheers,
    Benoit.
  • I have caught same problem

    One of my server have same error info,icegridnode couldnot start.but other server in different isp works fine with same config.
    os windows 2003 sp1.
    ice3.1.0

    I think some isp network envirment has used firewall makes icegride could not run.
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    If you want us to help you, could you please provide more information such as the error message printed by the IceGrid node? If you get an Ice::ConnectionRefusedException exception when starting the node, most likely it can't connect to the IceGrid registry, see this FAQ for more information on this exception.

    Cheers,
    Benoit.
Sign In or Register to comment.