Archived

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

Problem about proxy

Hello:
I met a problem about proxy:
I made 2 programs :A, B, and there are 2 instance of B in 2 different machines.
in A :
BPrx pB1=ic->stringToProxy("B:default -h machine1 -p 10000");
BPrx pB2=ic->stringToProxy("B:default -h machine2 -p 10000");
pB1->hello();
pB2->hello(); //ok
pB2->sayHello(pB1); //error if A is in machine 1

it is ok if A is running every machine but 1. when A is in machine 1, and when I invoke pB2->sayHello(pB1), pB2 will get it's own proxy through sayHello(BPrx), and say hello to itself. I have tested a lot times, and get the same results.

Comments

  • maybe I have know it, if I use localhost as ip, I'll get that error:

    and if I use absolute ip just like 168.1.0.1, it will be ok!

    I wonder how do you send a proxy? does it include the IP information?
  • benoit
    benoit Rennes, France
    Hi,

    Please don't post the same message twice.

    It's not clear to me what exactly is your problem. If you use "localhost" for the hostname, it's expected that invocations on the proxy will always be directed to the machine where the invocation is made.

    You shouldn't use "localhost" if you don't want this behavior but instead use the machine name or its IP address.

    Cheers,
    Benoit.
  • benoit wrote: »
    Hi,

    Please don't post the same message twice.

    It's not clear to me what exactly is your problem. If you use "localhost" for the hostname, it's expected that invocations on the proxy will always be directed to the machine where the invocation is made.

    You shouldn't use "localhost" if you don't want this behavior but instead use the machine name or its IP address.

    Cheers,
    Benoit.

    sorry, maybe I didnot express my question clearly.
    I just wonder the inside machansm of transmiting a proxy from one machine to another, and how could a proxy locate the real entity after it is received by another machine?
  • benoit
    benoit Rennes, France
    There's nothing magic happening when you transfer a proxy over the wire :). We just transfer the hostname or IP address of the proxy as is. So if you create a proxy from the string "hello:tcp -h foo.bar.com -p 12345" and transfer it over the wire to a peer, the peer will receive a proxy with the same host and port information (i.e.: foo.bar.com and 12345 respectively.)

    Cheers,
    Benoit.
  • oh, I see, thank you!

    if a proxy use "localhost" to locate a local entity, and after the proxy is transmited to another host, it will still keep "localhost" as its entity's address, is it? if so, if another machine also has an object with the same identity, the proxy will point to it? why don't map the "localhost" to its absolute IP befer transmiting a proxy? it could avoid the error!
  • marc
    marc Florida
    The absolute IP address of "localhost" is 127.0.0.1, which is loopback.

    We cannot simply replace localhost with the host's non-loopback IP address. If the user explicitly requests loopback, then this is what he should get. For example, you might want to use loopback if you always run your client and server locally, or you might use it for Glacier2 (our firewall) to communicate with a server located on the same host.

    In other words, if you don't want loopback, then don't tell Ice to use it. Simply don't use any -h option, or use -h <your_host_name>.