WildFly Server IP Address and Port

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

WildFly Server IP Address and Port

Arun Gupta
Assuming WildFly is bound to all available IP addresses using -b
0.0.0.0, is there a WildFly-specific API that can be used to obtain
the IP address where the server is running?

Ideally, I'd like something like:

WildFly.getHostAddress()
WildFly.getHostPort()

It could be running in a Docker container, in AWS, on my local laptop,
in OpenShift, or any where else and would like the IP address to be
returned correctly.

Suggestions?

Arun

--
http://blog.arungupta.me
http://twitter.com/arungupta
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Filippe Costa Spolti
Hello Arun,

I usethis code w/ Jboss 7 and wildfly 8, i didn't test with wildfly 9/10.

        MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
        String url = null;
        try {

            ObjectName http = new ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
            String jbossHttpAddress = (String) mBeanServer.getAttribute(http,"boundAddress");
            int jbossHttpPort = (Integer) mBeanServer.getAttribute(http,"boundPort");
            url = jbossHttpAddress + ":" + jbossHttpPort;
            log.fine("Url obtained from the system: " + url);
        } catch (Exception e) {
            log.severe(e.getStackTrace().toString());
        }
        return url;

regards.


On 09/01/2015 02:20 PM, Arun Gupta wrote:
Assuming WildFly is bound to all available IP addresses using -b
0.0.0.0, is there a WildFly-specific API that can be used to obtain
the IP address where the server is running?

Ideally, I'd like something like:

WildFly.getHostAddress()
WildFly.getHostPort()

It could be running in a Docker container, in AWS, on my local laptop,
in OpenShift, or any where else and would like the IP address to be
returned correctly.

Suggestions?

Arun



_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Bob McWhirter
Is this something JGroups/Clustering could use?  I've found that using 0.0.0.0 makes JGroups complain, because it has no idea which interface to actually use for multicast.


On Tue, Sep 1, 2015 at 2:25 PM, Filippe spolti <[hidden email]> wrote:
Hello Arun,

I usethis code w/ Jboss 7 and wildfly 8, i didn't test with wildfly 9/10.

        MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
        String url = null;
        try {

            ObjectName http = new ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
            String jbossHttpAddress = (String) mBeanServer.getAttribute(http,"boundAddress");
            int jbossHttpPort = (Integer) mBeanServer.getAttribute(http,"boundPort");
            url = jbossHttpAddress + ":" + jbossHttpPort;
            log.fine("Url obtained from the system: " + url);
        } catch (Exception e) {
            log.severe(e.getStackTrace().toString());
        }
        return url;

regards.


On 09/01/2015 02:20 PM, Arun Gupta wrote:
Assuming WildFly is bound to all available IP addresses using -b
0.0.0.0, is there a WildFly-specific API that can be used to obtain
the IP address where the server is running?

Ideally, I'd like something like:

WildFly.getHostAddress()
WildFly.getHostPort()

It could be running in a Docker container, in AWS, on my local laptop,
in OpenShift, or any where else and would like the IP address to be
returned correctly.

Suggestions?

Arun



_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Tristan Tarrant
You are getting the address of the public http interface which might not necessarily correspond to the port you want to use for clustering. 

--
Tristan Tarrant 
Infinispan Lead 
JBoss a division of Red Hat 

From: Bob McWhirter
Sent: 1 Sep 2015 19:39
To: Filippe spolti
Cc: [hidden email]
Subject: Re: [wildfly-dev] WildFly Server IP Address and Port


Is this something JGroups/Clustering could use?  I've found that using 0.0.0.0 makes JGroups complain, because it has no idea which interface to actually use for multicast.


On Tue, Sep 1, 2015 at 2:25 PM, Filippe spolti <[hidden email]> wrote:
Hello Arun,

I usethis code w/ Jboss 7 and wildfly 8, i didn't test with wildfly 9/10.

        MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
        String url = null;
        try {

            ObjectName http = new ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
            String jbossHttpAddress = (String) mBeanServer.getAttribute(http,"boundAddress");
            int jbossHttpPort = (Integer) mBeanServer.getAttribute(http,"boundPort");
            url = jbossHttpAddress + ":" + jbossHttpPort;
            log.fine("Url obtained from the system: " + url);
        } catch (Exception e) {
            log.severe(e.getStackTrace().toString());
        }
        return url;

regards.


On 09/01/2015 02:20 PM, Arun Gupta wrote:
Assuming WildFly is bound to all available IP addresses using -b
0.0.0.0, is there a WildFly-specific API that can be used to obtain
the IP address where the server is running?

Ideally, I'd like something like:

WildFly.getHostAddress()
WildFly.getHostPort()

It could be running in a Docker container, in AWS, on my local laptop,
in OpenShift, or any where else and would like the IP address to be
returned correctly.

Suggestions?

Arun



_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Brian Stansberry
In reply to this post by Filippe Costa Spolti
That JMX operation (or the CLI equivalent[1]) will return 0.0.0.0 which
really is the bound address but AIUI isn't what's wanted.

If the server is configured to use 0.0.0.0, there is no single
"WildFly.getHostAddress()". That setting means the relevant sockets will
be listening on all available interfaces on the machine. Which of those
is the one that's useful to a particular client depends on the network
topology.

BTW, if you know the names of the nics in your target environment but
don't know the addresses, WildFly (and EAP) let you configure the
interfaces to use a particular nic. If binding to 0.0.0.0 is a
workaround for not knowing the actual addresses, that may help. For example:

<interface name="public">
    <nic name="eth0"/>
</interface>

The 'name' attribute also allows expressions:

<nic name="${my.public.nic:eth0}"/>

With that kind of config, the JMX query Filippe showed will provide a
regular address.

[1] The CLI op:

[standalone@localhost:9990 /]
/socket-binding-group=standard-sockets/socket-binding=http:read-attribute(name=bound-address)
{
     "outcome" => "success",
     "result" => "0.0.0.0"
}

On 9/1/15 12:25 PM, Filippe spolti wrote:

> Hello Arun,
>
> I usethis code w/ Jboss 7 and wildfly 8, i didn't test with wildfly 9/10.
>
>          MBeanServer mBeanServer =
> ManagementFactory.getPlatformMBeanServer();
>          String url = null;
>          try {
>
>              ObjectName http = new
> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
>              String jbossHttpAddress = (String)
> mBeanServer.getAttribute(http,"boundAddress");
>              int jbossHttpPort = (Integer)
> mBeanServer.getAttribute(http,"boundPort");
>              url = jbossHttpAddress + ":" + jbossHttpPort;
>              log.fine("Url obtained from the system: " + url);
>          } catch (Exception e) {
>              log.severe(e.getStackTrace().toString());
>          }
>          return url;
>
> regards.
>
>
> On 09/01/2015 02:20 PM, Arun Gupta wrote:
>> Assuming WildFly is bound to all available IP addresses using -b
>> 0.0.0.0, is there a WildFly-specific API that can be used to obtain
>> the IP address where the server is running?
>>
>> Ideally, I'd like something like:
>>
>> WildFly.getHostAddress()
>> WildFly.getHostPort()
>>
>> It could be running in a Docker container, in AWS, on my local laptop,
>> in OpenShift, or any where else and would like the IP address to be
>> returned correctly.
>>
>> Suggestions?
>>
>> Arun
>>
>
>
>
> _______________________________________________
> wildfly-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>


--
Brian Stansberry
Senior Principal Software Engineer
JBoss by Red Hat
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Arun Gupta
Brian,

How do you envision this working in a Docker environment?

If multiple WildFly containers are running on the same Docker Host
(which is going to be common use case), should each WildFly be bound
to the IP address of the host?

Possibly invoked with a different port offset?

Arun

On Tue, Sep 1, 2015 at 1:31 PM, Brian Stansberry
<[hidden email]> wrote:

> That JMX operation (or the CLI equivalent[1]) will return 0.0.0.0 which
> really is the bound address but AIUI isn't what's wanted.
>
> If the server is configured to use 0.0.0.0, there is no single
> "WildFly.getHostAddress()". That setting means the relevant sockets will
> be listening on all available interfaces on the machine. Which of those
> is the one that's useful to a particular client depends on the network
> topology.
>
> BTW, if you know the names of the nics in your target environment but
> don't know the addresses, WildFly (and EAP) let you configure the
> interfaces to use a particular nic. If binding to 0.0.0.0 is a
> workaround for not knowing the actual addresses, that may help. For example:
>
> <interface name="public">
>     <nic name="eth0"/>
> </interface>
>
> The 'name' attribute also allows expressions:
>
> <nic name="${my.public.nic:eth0}"/>
>
> With that kind of config, the JMX query Filippe showed will provide a
> regular address.
>
> [1] The CLI op:
>
> [standalone@localhost:9990 /]
> /socket-binding-group=standard-sockets/socket-binding=http:read-attribute(name=bound-address)
> {
>      "outcome" => "success",
>      "result" => "0.0.0.0"
> }
>
> On 9/1/15 12:25 PM, Filippe spolti wrote:
>> Hello Arun,
>>
>> I usethis code w/ Jboss 7 and wildfly 8, i didn't test with wildfly 9/10.
>>
>>          MBeanServer mBeanServer =
>> ManagementFactory.getPlatformMBeanServer();
>>          String url = null;
>>          try {
>>
>>              ObjectName http = new
>> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
>>              String jbossHttpAddress = (String)
>> mBeanServer.getAttribute(http,"boundAddress");
>>              int jbossHttpPort = (Integer)
>> mBeanServer.getAttribute(http,"boundPort");
>>              url = jbossHttpAddress + ":" + jbossHttpPort;
>>              log.fine("Url obtained from the system: " + url);
>>          } catch (Exception e) {
>>              log.severe(e.getStackTrace().toString());
>>          }
>>          return url;
>>
>> regards.
>>
>>
>> On 09/01/2015 02:20 PM, Arun Gupta wrote:
>>> Assuming WildFly is bound to all available IP addresses using -b
>>> 0.0.0.0, is there a WildFly-specific API that can be used to obtain
>>> the IP address where the server is running?
>>>
>>> Ideally, I'd like something like:
>>>
>>> WildFly.getHostAddress()
>>> WildFly.getHostPort()
>>>
>>> It could be running in a Docker container, in AWS, on my local laptop,
>>> in OpenShift, or any where else and would like the IP address to be
>>> returned correctly.
>>>
>>> Suggestions?
>>>
>>> Arun
>>>
>>
>>
>>
>> _______________________________________________
>> wildfly-dev mailing list
>> [hidden email]
>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>>
>
>
> --
> Brian Stansberry
> Senior Principal Software Engineer
> JBoss by Red Hat
> _______________________________________________
> wildfly-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/wildfly-dev



--
http://blog.arungupta.me
http://twitter.com/arungupta
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Brian Stansberry
Is this scenario different from running multiple WildFly instances on a
single machine in a non-Docker setup?

If not, your choices are to associate each instance with a different
address, or to use port offsets. If there's only one available address
then you're down to port offsets.

On 9/1/15 4:34 PM, Arun Gupta wrote:

> Brian,
>
> How do you envision this working in a Docker environment?
>
> If multiple WildFly containers are running on the same Docker Host
> (which is going to be common use case), should each WildFly be bound
> to the IP address of the host?
>
> Possibly invoked with a different port offset?
>
> Arun
>
> On Tue, Sep 1, 2015 at 1:31 PM, Brian Stansberry
> <[hidden email]> wrote:
>> That JMX operation (or the CLI equivalent[1]) will return 0.0.0.0 which
>> really is the bound address but AIUI isn't what's wanted.
>>
>> If the server is configured to use 0.0.0.0, there is no single
>> "WildFly.getHostAddress()". That setting means the relevant sockets will
>> be listening on all available interfaces on the machine. Which of those
>> is the one that's useful to a particular client depends on the network
>> topology.
>>
>> BTW, if you know the names of the nics in your target environment but
>> don't know the addresses, WildFly (and EAP) let you configure the
>> interfaces to use a particular nic. If binding to 0.0.0.0 is a
>> workaround for not knowing the actual addresses, that may help. For example:
>>
>> <interface name="public">
>>      <nic name="eth0"/>
>> </interface>
>>
>> The 'name' attribute also allows expressions:
>>
>> <nic name="${my.public.nic:eth0}"/>
>>
>> With that kind of config, the JMX query Filippe showed will provide a
>> regular address.
>>
>> [1] The CLI op:
>>
>> [standalone@localhost:9990 /]
>> /socket-binding-group=standard-sockets/socket-binding=http:read-attribute(name=bound-address)
>> {
>>       "outcome" => "success",
>>       "result" => "0.0.0.0"
>> }
>>
>> On 9/1/15 12:25 PM, Filippe spolti wrote:
>>> Hello Arun,
>>>
>>> I usethis code w/ Jboss 7 and wildfly 8, i didn't test with wildfly 9/10.
>>>
>>>           MBeanServer mBeanServer =
>>> ManagementFactory.getPlatformMBeanServer();
>>>           String url = null;
>>>           try {
>>>
>>>               ObjectName http = new
>>> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
>>>               String jbossHttpAddress = (String)
>>> mBeanServer.getAttribute(http,"boundAddress");
>>>               int jbossHttpPort = (Integer)
>>> mBeanServer.getAttribute(http,"boundPort");
>>>               url = jbossHttpAddress + ":" + jbossHttpPort;
>>>               log.fine("Url obtained from the system: " + url);
>>>           } catch (Exception e) {
>>>               log.severe(e.getStackTrace().toString());
>>>           }
>>>           return url;
>>>
>>> regards.
>>>
>>>
>>> On 09/01/2015 02:20 PM, Arun Gupta wrote:
>>>> Assuming WildFly is bound to all available IP addresses using -b
>>>> 0.0.0.0, is there a WildFly-specific API that can be used to obtain
>>>> the IP address where the server is running?
>>>>
>>>> Ideally, I'd like something like:
>>>>
>>>> WildFly.getHostAddress()
>>>> WildFly.getHostPort()
>>>>
>>>> It could be running in a Docker container, in AWS, on my local laptop,
>>>> in OpenShift, or any where else and would like the IP address to be
>>>> returned correctly.
>>>>
>>>> Suggestions?
>>>>
>>>> Arun
>>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> wildfly-dev mailing list
>>> [hidden email]
>>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>>>
>>
>>
>> --
>> Brian Stansberry
>> Senior Principal Software Engineer
>> JBoss by Red Hat
>> _______________________________________________
>> wildfly-dev mailing list
>> [hidden email]
>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>
>
>


--
Brian Stansberry
Senior Principal Software Engineer
JBoss by Red Hat
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Arun Gupta
On Tue, Sep 1, 2015 at 3:33 PM, Brian Stansberry
<[hidden email]> wrote:
> Is this scenario different from running multiple WildFly instances on a
> single machine in a non-Docker setup?

Good point, they are the same.

>
> If not, your choices are to associate each instance with a different
> address, or to use port offsets. If there's only one available address then
> you're down to port offsets.


So, if WildFly runs with -b <IP_ADDRESS> then the utility above will
give the correct address and port?

Arun

>
>
> On 9/1/15 4:34 PM, Arun Gupta wrote:
>>
>> Brian,
>>
>> How do you envision this working in a Docker environment?
>>
>> If multiple WildFly containers are running on the same Docker Host
>> (which is going to be common use case), should each WildFly be bound
>> to the IP address of the host?
>>
>> Possibly invoked with a different port offset?
>>
>> Arun
>>
>> On Tue, Sep 1, 2015 at 1:31 PM, Brian Stansberry
>> <[hidden email]> wrote:
>>>
>>> That JMX operation (or the CLI equivalent[1]) will return 0.0.0.0 which
>>> really is the bound address but AIUI isn't what's wanted.
>>>
>>> If the server is configured to use 0.0.0.0, there is no single
>>> "WildFly.getHostAddress()". That setting means the relevant sockets will
>>> be listening on all available interfaces on the machine. Which of those
>>> is the one that's useful to a particular client depends on the network
>>> topology.
>>>
>>> BTW, if you know the names of the nics in your target environment but
>>> don't know the addresses, WildFly (and EAP) let you configure the
>>> interfaces to use a particular nic. If binding to 0.0.0.0 is a
>>> workaround for not knowing the actual addresses, that may help. For
>>> example:
>>>
>>> <interface name="public">
>>>      <nic name="eth0"/>
>>> </interface>
>>>
>>> The 'name' attribute also allows expressions:
>>>
>>> <nic name="${my.public.nic:eth0}"/>
>>>
>>> With that kind of config, the JMX query Filippe showed will provide a
>>> regular address.
>>>
>>> [1] The CLI op:
>>>
>>> [standalone@localhost:9990 /]
>>>
>>> /socket-binding-group=standard-sockets/socket-binding=http:read-attribute(name=bound-address)
>>> {
>>>       "outcome" => "success",
>>>       "result" => "0.0.0.0"
>>> }
>>>
>>> On 9/1/15 12:25 PM, Filippe spolti wrote:
>>>>
>>>> Hello Arun,
>>>>
>>>> I usethis code w/ Jboss 7 and wildfly 8, i didn't test with wildfly
>>>> 9/10.
>>>>
>>>>           MBeanServer mBeanServer =
>>>> ManagementFactory.getPlatformMBeanServer();
>>>>           String url = null;
>>>>           try {
>>>>
>>>>               ObjectName http = new
>>>>
>>>> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
>>>>               String jbossHttpAddress = (String)
>>>> mBeanServer.getAttribute(http,"boundAddress");
>>>>               int jbossHttpPort = (Integer)
>>>> mBeanServer.getAttribute(http,"boundPort");
>>>>               url = jbossHttpAddress + ":" + jbossHttpPort;
>>>>               log.fine("Url obtained from the system: " + url);
>>>>           } catch (Exception e) {
>>>>               log.severe(e.getStackTrace().toString());
>>>>           }
>>>>           return url;
>>>>
>>>> regards.
>>>>
>>>>
>>>> On 09/01/2015 02:20 PM, Arun Gupta wrote:
>>>>>
>>>>> Assuming WildFly is bound to all available IP addresses using -b
>>>>> 0.0.0.0, is there a WildFly-specific API that can be used to obtain
>>>>> the IP address where the server is running?
>>>>>
>>>>> Ideally, I'd like something like:
>>>>>
>>>>> WildFly.getHostAddress()
>>>>> WildFly.getHostPort()
>>>>>
>>>>> It could be running in a Docker container, in AWS, on my local laptop,
>>>>> in OpenShift, or any where else and would like the IP address to be
>>>>> returned correctly.
>>>>>
>>>>> Suggestions?
>>>>>
>>>>> Arun
>>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> wildfly-dev mailing list
>>>> [hidden email]
>>>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>>>>
>>>
>>>
>>> --
>>> Brian Stansberry
>>> Senior Principal Software Engineer
>>> JBoss by Red Hat
>>> _______________________________________________
>>> wildfly-dev mailing list
>>> [hidden email]
>>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>>
>>
>>
>>
>
>
> --
> Brian Stansberry
> Senior Principal Software Engineer
> JBoss by Red Hat



--
http://blog.arungupta.me
http://twitter.com/arungupta
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Arun Gupta
In reply to this post by Filippe Costa Spolti
Filippe,

Somebody coded the utility as shown at:

https://github.com/arun-gupta/microservices/blob/master/microservice/utils/src/main/java/org/javaee7/wildfly/samples/everest/utils/WildflyUtil.java#L46

But I guess yours is the correct way. WDYT?

Arun

On Tue, Sep 1, 2015 at 10:25 AM, Filippe spolti <[hidden email]> wrote:

> Hello Arun,
>
> I usethis code w/ Jboss 7 and wildfly 8, i didn't test with wildfly 9/10.
>
>         MBeanServer mBeanServer =
> ManagementFactory.getPlatformMBeanServer();
>         String url = null;
>         try {
>
>             ObjectName http = new
> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
>             String jbossHttpAddress = (String)
> mBeanServer.getAttribute(http,"boundAddress");
>             int jbossHttpPort = (Integer)
> mBeanServer.getAttribute(http,"boundPort");
>             url = jbossHttpAddress + ":" + jbossHttpPort;
>             log.fine("Url obtained from the system: " + url);
>         } catch (Exception e) {
>             log.severe(e.getStackTrace().toString());
>         }
>         return url;
>
> regards.
>
>
> On 09/01/2015 02:20 PM, Arun Gupta wrote:
>
> Assuming WildFly is bound to all available IP addresses using -b
> 0.0.0.0, is there a WildFly-specific API that can be used to obtain
> the IP address where the server is running?
>
> Ideally, I'd like something like:
>
> WildFly.getHostAddress()
> WildFly.getHostPort()
>
> It could be running in a Docker container, in AWS, on my local laptop,
> in OpenShift, or any where else and would like the IP address to be
> returned correctly.
>
> Suggestions?
>
> Arun
>
>
>
> _______________________________________________
> wildfly-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/wildfly-dev



--
http://blog.arungupta.me
http://twitter.com/arungupta
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Brian Stansberry
In reply to this post by Arun Gupta
On 9/1/15 5:47 PM, Arun Gupta wrote:
> On Tue, Sep 1, 2015 at 3:33 PM, Brian Stansberry
> <[hidden email]> wrote:
>> Is this scenario different from running multiple WildFly instances on a
>> single machine in a non-Docker setup?
>
> Good point, they are the same.
>

Reading a bit more, it seems Docker gives each container its own
address, visible to the container via the eth0 interface:

https://docs.docker.com/articles/networking/

>>
>> If not, your choices are to associate each instance with a different
>> address, or to use port offsets. If there's only one available address then
>> you're down to port offsets.
>
>
> So, if WildFly runs with -b <IP_ADDRESS> then the utility above will
> give the correct address and port?
>

Yes, assuming IP_ADDRESS != 0.0.0.0, the server config is using a
socket-binding named "http" for the web server, and the web server
address/port is the one you want.

> Arun
>
>>
>>
>> On 9/1/15 4:34 PM, Arun Gupta wrote:
>>>
>>> Brian,
>>>
>>> How do you envision this working in a Docker environment?
>>>
>>> If multiple WildFly containers are running on the same Docker Host
>>> (which is going to be common use case), should each WildFly be bound
>>> to the IP address of the host?
>>>
>>> Possibly invoked with a different port offset?
>>>
>>> Arun
>>>
>>> On Tue, Sep 1, 2015 at 1:31 PM, Brian Stansberry
>>> <[hidden email]> wrote:
>>>>
>>>> That JMX operation (or the CLI equivalent[1]) will return 0.0.0.0 which
>>>> really is the bound address but AIUI isn't what's wanted.
>>>>
>>>> If the server is configured to use 0.0.0.0, there is no single
>>>> "WildFly.getHostAddress()". That setting means the relevant sockets will
>>>> be listening on all available interfaces on the machine. Which of those
>>>> is the one that's useful to a particular client depends on the network
>>>> topology.
>>>>
>>>> BTW, if you know the names of the nics in your target environment but
>>>> don't know the addresses, WildFly (and EAP) let you configure the
>>>> interfaces to use a particular nic. If binding to 0.0.0.0 is a
>>>> workaround for not knowing the actual addresses, that may help. For
>>>> example:
>>>>
>>>> <interface name="public">
>>>>       <nic name="eth0"/>
>>>> </interface>
>>>>
>>>> The 'name' attribute also allows expressions:
>>>>
>>>> <nic name="${my.public.nic:eth0}"/>
>>>>
>>>> With that kind of config, the JMX query Filippe showed will provide a
>>>> regular address.
>>>>
>>>> [1] The CLI op:
>>>>
>>>> [standalone@localhost:9990 /]
>>>>
>>>> /socket-binding-group=standard-sockets/socket-binding=http:read-attribute(name=bound-address)
>>>> {
>>>>        "outcome" => "success",
>>>>        "result" => "0.0.0.0"
>>>> }
>>>>
>>>> On 9/1/15 12:25 PM, Filippe spolti wrote:
>>>>>
>>>>> Hello Arun,
>>>>>
>>>>> I usethis code w/ Jboss 7 and wildfly 8, i didn't test with wildfly
>>>>> 9/10.
>>>>>
>>>>>            MBeanServer mBeanServer =
>>>>> ManagementFactory.getPlatformMBeanServer();
>>>>>            String url = null;
>>>>>            try {
>>>>>
>>>>>                ObjectName http = new
>>>>>
>>>>> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
>>>>>                String jbossHttpAddress = (String)
>>>>> mBeanServer.getAttribute(http,"boundAddress");
>>>>>                int jbossHttpPort = (Integer)
>>>>> mBeanServer.getAttribute(http,"boundPort");
>>>>>                url = jbossHttpAddress + ":" + jbossHttpPort;
>>>>>                log.fine("Url obtained from the system: " + url);
>>>>>            } catch (Exception e) {
>>>>>                log.severe(e.getStackTrace().toString());
>>>>>            }
>>>>>            return url;
>>>>>
>>>>> regards.
>>>>>
>>>>>
>>>>> On 09/01/2015 02:20 PM, Arun Gupta wrote:
>>>>>>
>>>>>> Assuming WildFly is bound to all available IP addresses using -b
>>>>>> 0.0.0.0, is there a WildFly-specific API that can be used to obtain
>>>>>> the IP address where the server is running?
>>>>>>
>>>>>> Ideally, I'd like something like:
>>>>>>
>>>>>> WildFly.getHostAddress()
>>>>>> WildFly.getHostPort()
>>>>>>
>>>>>> It could be running in a Docker container, in AWS, on my local laptop,
>>>>>> in OpenShift, or any where else and would like the IP address to be
>>>>>> returned correctly.
>>>>>>
>>>>>> Suggestions?
>>>>>>
>>>>>> Arun
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> wildfly-dev mailing list
>>>>> [hidden email]
>>>>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>>>>>
>>>>
>>>>
>>>> --
>>>> Brian Stansberry
>>>> Senior Principal Software Engineer
>>>> JBoss by Red Hat
>>>> _______________________________________________
>>>> wildfly-dev mailing list
>>>> [hidden email]
>>>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>>>
>>>
>>>
>>>
>>
>>
>> --
>> Brian Stansberry
>> Senior Principal Software Engineer
>> JBoss by Red Hat
>
>
>


--
Brian Stansberry
Senior Principal Software Engineer
JBoss by Red Hat
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Arun Gupta
>>> Is this scenario different from running multiple WildFly instances on a
>>> single machine in a non-Docker setup?
>>
>>
>> Good point, they are the same.
>>
>
> Reading a bit more, it seems Docker gives each container its own address,
> visible to the container via the eth0 interface:
>
> https://docs.docker.com/articles/networking/

Those IP addresses are not available externally AIU.

>> So, if WildFly runs with -b <IP_ADDRESS> then the utility above will
>> give the correct address and port?
>>
>
> Yes, assuming IP_ADDRESS != 0.0.0.0, the server config is using a
> socket-binding named "http" for the web server, and the web server
> address/port is the one you want.
>

            ObjectName http = new
ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
            hostName = (String) mBeanServer.getAttribute(http,"boundAddress");
            hostPort = (Integer) mBeanServer.getAttribute(http,"boundPort");


seems to be returning correct HTTP host/port. However

            ObjectName https = new
ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=https");
            hostSecurePort = (int) mBeanServer.getAttribute(https, "boundPort");

is throwing NPE.

Will this only be available if HTTPS port is accessible?

Arun



--
http://blog.arungupta.me
http://twitter.com/arungupta
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Brian Stansberry
On 9/1/15 6:52 PM, Arun Gupta wrote:

>>>> Is this scenario different from running multiple WildFly instances on a
>>>> single machine in a non-Docker setup?
>>>
>>>
>>> Good point, they are the same.
>>>
>>
>> Reading a bit more, it seems Docker gives each container its own address,
>> visible to the container via the eth0 interface:
>>
>> https://docs.docker.com/articles/networking/
>
> Those IP addresses are not available externally AIU.
>

Ok, I'm getting clear on your scenario. Thanks.

>>> So, if WildFly runs with -b <IP_ADDRESS> then the utility above will
>>> give the correct address and port?
>>>
>>
>> Yes, assuming IP_ADDRESS != 0.0.0.0, the server config is using a
>> socket-binding named "http" for the web server, and the web server
>> address/port is the one you want.
>>
>
>              ObjectName http = new
> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
>              hostName = (String) mBeanServer.getAttribute(http,"boundAddress");
>              hostPort = (Integer) mBeanServer.getAttribute(http,"boundPort");
>
>
> seems to be returning correct HTTP host/port. However
>
>              ObjectName https = new
> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=https");
>              hostSecurePort = (int) mBeanServer.getAttribute(https, "boundPort");
>
> is throwing NPE.
>
> Will this only be available if HTTPS port is accessible?
>

Those attributes will only be non-null if the https socket-binding is
used by some service (e.g. an undertow listener.) If the configuration
doesn't require the socket binding to be used, then the resolution of
the socket binding's config data to an actual IP address will not occur.

> Arun
>
>
>


--
Brian Stansberry
Senior Principal Software Engineer
JBoss by Red Hat
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Bob McWhirter
We do support some way to advertise (via jgroups) a different host/port than the one that it is actually bound to, right?

I thought we had to add that functionality to support OpenShift, where the internal IP given to the AS is different than the externally visible host/port for clustering.

On Wed, Sep 2, 2015 at 10:20 AM, Brian Stansberry <[hidden email]> wrote:
On 9/1/15 6:52 PM, Arun Gupta wrote:
>>>> Is this scenario different from running multiple WildFly instances on a
>>>> single machine in a non-Docker setup?
>>>
>>>
>>> Good point, they are the same.
>>>
>>
>> Reading a bit more, it seems Docker gives each container its own address,
>> visible to the container via the eth0 interface:
>>
>> https://docs.docker.com/articles/networking/
>
> Those IP addresses are not available externally AIU.
>

Ok, I'm getting clear on your scenario. Thanks.

>>> So, if WildFly runs with -b <IP_ADDRESS> then the utility above will
>>> give the correct address and port?
>>>
>>
>> Yes, assuming IP_ADDRESS != 0.0.0.0, the server config is using a
>> socket-binding named "http" for the web server, and the web server
>> address/port is the one you want.
>>
>
>              ObjectName http = new
> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
>              hostName = (String) mBeanServer.getAttribute(http,"boundAddress");
>              hostPort = (Integer) mBeanServer.getAttribute(http,"boundPort");
>
>
> seems to be returning correct HTTP host/port. However
>
>              ObjectName https = new
> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=https");
>              hostSecurePort = (int) mBeanServer.getAttribute(https, "boundPort");
>
> is throwing NPE.
>
> Will this only be available if HTTPS port is accessible?
>

Those attributes will only be non-null if the https socket-binding is
used by some service (e.g. an undertow listener.) If the configuration
doesn't require the socket binding to be used, then the resolution of
the socket binding's config data to an actual IP address will not occur.

> Arun
>
>
>


--
Brian Stansberry
Senior Principal Software Engineer
JBoss by Red Hat
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Brian Stansberry
I believe you are referring to the "external_addr" configuration
property available for JGroups transport protocols:

http://www.jgroups.org/manual/html/protlist.html#Transport

I didn't follow the development of that feature in detail, but I assume
the way it works is the JGroups discovery protocols advertise the value
of that property if it's configured. Otherwise they advertise the usual
bind_addr.

That's specific to JGroups discovery though. It's not a general purpose
service endpoint publication and discovery thing. I've seen systems like
Kubernetes used for that kind of orchestration.

On 9/2/15 8:23 AM, Bob McWhirter wrote:

> We do support some way to advertise (via jgroups) a different host/port
> than the one that it is actually bound to, right?
>
> I thought we had to add that functionality to support OpenShift, where
> the internal IP given to the AS is different than the externally visible
> host/port for clustering.
>
> On Wed, Sep 2, 2015 at 10:20 AM, Brian Stansberry
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     On 9/1/15 6:52 PM, Arun Gupta wrote:
>     >>>> Is this scenario different from running multiple WildFly instances on a
>     >>>> single machine in a non-Docker setup?
>     >>>
>     >>>
>     >>> Good point, they are the same.
>     >>>
>     >>
>     >> Reading a bit more, it seems Docker gives each container its own address,
>     >> visible to the container via the eth0 interface:
>     >>
>     >>https://docs.docker.com/articles/networking/
>     >
>     > Those IP addresses are not available externally AIU.
>     >
>
>     Ok, I'm getting clear on your scenario. Thanks.
>
>     >>> So, if WildFly runs with -b <IP_ADDRESS> then the utility above will
>     >>> give the correct address and port?
>     >>>
>     >>
>     >> Yes, assuming IP_ADDRESS != 0.0.0.0, the server config is using a
>     >> socket-binding named "http" for the web server, and the web server
>     >> address/port is the one you want.
>     >>
>     >
>     >              ObjectName http = new
>     > ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
>     >              hostName = (String) mBeanServer.getAttribute(http,"boundAddress");
>     >              hostPort = (Integer) mBeanServer.getAttribute(http,"boundPort");
>     >
>     >
>     > seems to be returning correct HTTP host/port. However
>     >
>     >              ObjectName https = new
>     > ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=https");
>     >              hostSecurePort = (int) mBeanServer.getAttribute(https, "boundPort");
>     >
>     > is throwing NPE.
>     >
>     > Will this only be available if HTTPS port is accessible?
>     >
>
>     Those attributes will only be non-null if the https socket-binding is
>     used by some service (e.g. an undertow listener.) If the configuration
>     doesn't require the socket binding to be used, then the resolution of
>     the socket binding's config data to an actual IP address will not occur.
>
>      > Arun
>     >
>     >
>     >
>
>
>     --
>     Brian Stansberry
>     Senior Principal Software Engineer
>     JBoss by Red Hat
>     _______________________________________________
>     wildfly-dev mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.jboss.org/mailman/listinfo/wildfly-dev
>
>


--
Brian Stansberry
Senior Principal Software Engineer
JBoss by Red Hat
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: WildFly Server IP Address and Port

Arun Gupta
In reply to this post by Brian Stansberry
Next issue with this usage ...

Starting the command "/opt/jboss/wildfly/bin/standalone.sh -b
192.168.99.100" inside the container gives the following error ...

22:27:00,265 INFO  [org.xnio.nio] (MSC service thread 1-2) XNIO NIO
Implementation Version 3.3.1.Final
22:27:00,287 ERROR [org.jboss.msc.service.fail] (MSC service thread
1-1) MSC000001: Failed to start service jboss.network.public:
org.jboss.msc.service.StartException in service jboss.network.public:
WFLYSRV0082: failed to resolve interface public
at org.jboss.as.server.services.net.NetworkInterfaceService.start(NetworkInterfaceService.java:91)
[wildfly-server-1.0.1.Final.jar:1.0.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
[jboss-msc-1.2.6.Final.jar:1.2.6.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
[jboss-msc-1.2.6.Final.jar:1.2.6.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[rt.jar:1.8.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[rt.jar:1.8.0_51]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]

This is expected because 192.168.99.100 is IP Address of Docker Host.
Seems like I may have to use the internal IP address. Any thoughts on
how to obtain it?

And even then, not sure if this will allow jboss-cli to return the
publicly exposed IP address, i.e. of Docker Host.

Thoughts?

Arun

On Wed, Sep 2, 2015 at 6:20 AM, Brian Stansberry
<[hidden email]> wrote:

> On 9/1/15 6:52 PM, Arun Gupta wrote:
>>>>>
>>>>> Is this scenario different from running multiple WildFly instances on a
>>>>> single machine in a non-Docker setup?
>>>>
>>>>
>>>>
>>>> Good point, they are the same.
>>>>
>>>
>>> Reading a bit more, it seems Docker gives each container its own address,
>>> visible to the container via the eth0 interface:
>>>
>>> https://docs.docker.com/articles/networking/
>>
>>
>> Those IP addresses are not available externally AIU.
>>
>
> Ok, I'm getting clear on your scenario. Thanks.
>
>>>> So, if WildFly runs with -b <IP_ADDRESS> then the utility above will
>>>> give the correct address and port?
>>>>
>>>
>>> Yes, assuming IP_ADDRESS != 0.0.0.0, the server config is using a
>>> socket-binding named "http" for the web server, and the web server
>>> address/port is the one you want.
>>>
>>
>>              ObjectName http = new
>>
>> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
>>              hostName = (String)
>> mBeanServer.getAttribute(http,"boundAddress");
>>              hostPort = (Integer)
>> mBeanServer.getAttribute(http,"boundPort");
>>
>>
>> seems to be returning correct HTTP host/port. However
>>
>>              ObjectName https = new
>>
>> ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=https");
>>              hostSecurePort = (int) mBeanServer.getAttribute(https,
>> "boundPort");
>>
>> is throwing NPE.
>>
>> Will this only be available if HTTPS port is accessible?
>>
>
> Those attributes will only be non-null if the https socket-binding is used
> by some service (e.g. an undertow listener.) If the configuration doesn't
> require the socket binding to be used, then the resolution of the socket
> binding's config data to an actual IP address will not occur.
>
>> Arun
>>
>>
>>
>
>
> --
> Brian Stansberry
> Senior Principal Software Engineer
> JBoss by Red Hat



--
http://blog.arungupta.me
http://twitter.com/arungupta
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev