Archived

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

how to listen on 0.0.0.0 and register to registry?

hi, i have any problem now. I need to setup an adapter and listening on one port, if i set endpoints as "default -p xxxxx", it will auto search an ip(not 0.0.0.0) and listen, seems work well, but if I change the IP address, netstat shows that it still listen on old ip, and not work. but if i set endpoints as "default -h 0.0.0.0 -p xxxx", it resolve that problem, but rise new problem, that is: if i registry my object to icepackregistry, it will not work, and i use icepackadmin to find object, shows "MyObject:default -h 0.0.0.0 -p xxxx", so lookup service not work.

how to resolve this problem? help plz.

Comments

  • benoit
    benoit Rennes, France
    If you set the adapter endpoint to "default -p <PORT> -h <IP address>" in the deployment descriptor -- that's what you should see in the registry after you deploy or update the application. If this doesn't work for you, could you provide more details on how to reproduce the problem?

    After starting your server, you can check the adapter endpoints with the "adapter endpoints <AdapterId>" IcePack admin command. Also, note that if you change the deployment descriptor, you need to update the deployment with "application update <descriptor.xml>".

    Benoit.
  • thanks for reply

    what i want to know is : How to set an adapter to listen on 0.0.0.0 so it can still work after people change the network interface ip, for you know, i start apache, netstat will show 0.0.0.0:80 listenning, not my ip like 10.0.0.42:80 listening. the way i thought is to use -h 0.0.0.0, but it cannot work on registry
  • more detail,
    for example, i have an computer which has two interface : eth0 and eth1
    eth0 is set to 10.0.0.42
    eth1 is set to 192.168.0.42
    if i use default -p 20000
    netstat show:
    10.0.0.42:20000 listenning
    so, it cannot work on 192.168.0.42
    apache will be:
    0.0.0.0:80 listenning
    what i want to know is how to do like apache does, and still work on registry
  • benoit
    benoit Rennes, France
    I'm afraid that's not possible. If the object adapter endpoint IP address is 0.0.0.0 (to listen on all the interfaces) then that's what will get registered in the registry. Ice can't figure out the IP addresses of all the interfaces the object adapter will be listening on when you specify 0.0.0.0.

    If you want to listen on multiple interfaces, it's better to use multiple endpoints, for example: "default -p 12000 -h 192.168.0.1:default -p 12000 -h 10.0.0.1".

    Benoit.
  • benoit wrote:
    I'm afraid that's not possible. If the object adapter endpoint IP address is 0.0.0.0 (to listen on all the interfaces) then that's what will get registered in the registry. Ice can't figure out the IP addresses of all the interfaces the object adapter will be listening on when you specify 0.0.0.0.

    If you want to listen on multiple interfaces, it's better to use multiple endpoints, for example: "default -p 12000 -h 192.168.0.1:default -p 12000 -h 10.0.0.1".

    Benoit.

    your answer is reasonable, for if one adapter change it's ip without re-register in the registry, registry didn't know where to find the adapter. but multiple endpoints is not so convinenble, any good solution? need a program to listen for the event for ip changing, and if found , re-register on the reigstry? is this the best way?
  • benoit
    benoit Rennes, France
    I'm not quite sure I understand your question.

    If the IP address of an interface changes, you'll need to update the IcePack registry with the new IP address. Another solution is to not use IP addresses for endpoints but instead use hostnames (specified in /etc/hosts or a DNS server). This way you won't have to update the IcePack registry (you'll have to update the /etc/hosts file though!).

    For example, if your host has 2 interfaces eth0 and eth1, you could assign a hostname for each interface:
    /etc/hosts:
    
      192.168.0.1 myhost-eth0
      10.0.0.1 myhost-eth1
    

    The adapter endpoint would be: "default -p 12000 -h myhost-eth0:default -p 12000 -h myhost-eth1".

    Btw, for more information about the use of 0.0.0.0 (aka INADDR_ANY) in object adapter endpoints, you can also check [thread=343]this thread[/thread].

    Let me know if this still doesn't answer your question!

    Benoit.