Archived

This forum has been archived. Please start a new discussion on GitHub.

IceStorm ConnectionRefusedException

Hello.
I am trying the example about IceStorm from de pdf. I am using Ice 3.3.1, in an ubuntu 8.04 distro. I have just compiled and linked the publisher and the subscriber, and I have added the lines:
Ice::CommunicatorPtr communicator;
communicator = Ice::initialize(argc, argv);

because when I was compiling, communicator wasn't declared.
The problem is that when I am going to execute the subscriber, it throws the following exception:
terminate called after throwing an instance of 'Ice::ConnectionRefusedException'
what(): Network.cpp:1220: Ice::ConnectionRefusedException:

I have used the --Ice.Trace.Network=2, in order to see what was happening, and the result was:

local address = 127.0.0.1:59622
remote address = <not connected>

So I suspect that subscriber is trying to connect to another machine, but, why is this happening? I supposed that subscriber acts like a server, and publisher like a client.
any help?
Thanks.

Comments

  • dwayne
    dwayne St. John's, Newfoundland
    While for normal event flow the publisher acts as a client and the subscriber as a server, at first the subscriber needs to contact the IceStorm service in order to register to receive events for the topic(s) it is interested in. In this case the subscriber is the client and IceStorm is the server. Most likely this is the connection attempt that is failing for you. You should make sure that the IceStorm TopicManager proxy you are using in the subscriber has the correct host/port settings.
  • Thank you for the fast response!
    My code for the subscriber is this (based on the example):
    Ice::CommunicatorPtr communicator;
    communicator = Ice::initialize(argc, argv);
    Ice::ObjectPrx obj = communicator->stringToProxy("IceStorm/TopicManager:tcp -p 9999");
    IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(obj);
    

    I have ensured that my firewall isn't blocking that port.
    What am I doing wrong?
    Thanks.
  • dwayne
    dwayne St. John's, Newfoundland
    What does your IceStorm configuration look like? Is it listening on port 9999? Is it running on the same host as your publisher? You are not specifying a host in your IceStorm proxy, meaning the subscriber will only try to connect using the loopback interface. Perhaps you need to specify a host using the "-h" option.

    Running both IceStorm and your subscriber with --Ice.Network=2 should help you figure out what is happening. You could also post those traces here if you need further help.
  • Yes, both the publisher and the subscriber are running in the same host, that's why I didn't specified the host.
    But, I think that I am disregarding something important, what do you mean when you say "Running both IceStorm and your subscriber"?
    I have just two exec's, a publisher and a subscriber, and I'm trying to run the subscriber and then the publisher, but I haven't got any IceStorm.
    The traces:

    The subscriber:
    $ ./sub --Ice.Trace.Network=2
    [ 06/26/09 18:38:46.085 Network: trying to establish tcp connection to 127.0.0.1:9999 ]
    [ 06/26/09 18:38:46.085 Network: failed to establish tcp connection
    local address = 127.0.0.1:46843
    remote address = <not connected>
    Network.cpp:1220: Ice::ConnectionRefusedException:
    connection refused: Connection refused ]
    [ 06/26/09 18:38:46.086 Network: closing tcp connection
    local address = 127.0.0.1:46843
    remote address = <not connected> ]
    [ 06/26/09 18:38:46.086 Network: trying to establish tcp connection to 127.0.0.1:9999 ]
    [ 06/26/09 18:38:46.086 Network: failed to establish tcp connection
    local address = 127.0.0.1:46844
    remote address = <not connected>
    Network.cpp:1220: Ice::ConnectionRefusedException:
    connection refused: Connection refused ]
    [ 06/26/09 18:38:46.086 Network: closing tcp connection
    local address = 127.0.0.1:46844
    remote address = <not connected> ]
    terminate called after throwing an instance of 'Ice::ConnectionRefusedException'
    what(): Network.cpp:1220: Ice::ConnectionRefusedException:
    connection refused: Connection refused
    Cancelado

    The publisher:
    $ ./pub --Ice.Trace.Network=2
    +[ 06/26/09 18:38:54.997 Network: trying to establish tcp connection to 127.0.0.1:9999 ]
    [ 06/26/09 18:38:54.997 Network: failed to establish tcp connection
    local address = 127.0.0.1:46845
    remote address = <not connected>
    Network.cpp:1220: Ice::ConnectionRefusedException:
    connection refused: Connection refused ]
    [ 06/26/09 18:38:54.998 Network: closing tcp connection
    local address = 127.0.0.1:46845
    remote address = <not connected> ]
    [ 06/26/09 18:38:54.998 Network: trying to establish tcp connection to 127.0.0.1:9999 ]
    [ 06/26/09 18:38:54.998 Network: failed to establish tcp connection
    local address = 127.0.0.1:46846
    remote address = <not connected>
    Network.cpp:1220: Ice::ConnectionRefusedException:
    connection refused: Connection refused ]
    [ 06/26/09 18:38:54.998 Network: closing tcp connection
    local address = 127.0.0.1:46846
    remote address = <not connected> ]
    terminate called after throwing an instance of 'Ice::ConnectionRefusedException'
    what(): Network.cpp:1220: Ice::ConnectionRefusedException:
    connection refused: Connection refused
    Cancelado

    Thank you.
  • dwayne
    dwayne St. John's, Newfoundland
    Raul wrote: »
    But, I think that I am disregarding something important, what do you mean when you say "Running both IceStorm and your subscriber"?
    I have just two exec's, a publisher and a subscriber, and I'm trying to run the subscriber and then the publisher, but I haven't got any IceStorm.

    Well, that is your problem then. You need to run the IceStorm service as well as the publisher and subscriber in order for this to work. You should take a look at one of the demos that come with Ice such as demo/IceStorm/clock to see a complete example. With IceStorm the publishers and subscribers are decoupled and all event flow goes through the IceStorm service. Publishers send events to IceStorm on a specific topic and then IceStorm distributes these events to all subscribers that are registered on that topic.
  • Perfect!
    Thank you very much for all the help.
    I have just tried and understood the example, now I'm going to modify my app.
    Thanks.