[ 
https://issues.apache.org/jira/browse/CASSANDRA-9137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14486814#comment-14486814
 ] 

Andrey Trubachev edited comment on CASSANDRA-9137 at 4/9/15 6:38 AM:
---------------------------------------------------------------------

I've made extra checks
{code}
String localhostIP = InetAddress.getLoopbackAddress().getHostAddress();
System.out.println(localhostIP);
{code}
and this code returns {{127.0.0.1}} or {{0:0:0:0:0:0:0:1}} when 
{{java.net.preferIPv6Addresses}} is {{true}}.
Unfortunately, I'm not experienced enough in Java to explain it in more details.


was (Author: d3rp):
I've made extra checks
{code}
String localhostIP = InetAddress.getLoopbackAddress().getHostAddress();
System.out.println(localhostIP);
{code}
and this code returns {{127.0.0.1}} or {{0:0:0:0:0:0:0:1}} when 
{{java.net.preferIPv6Addresses}} is {{true}}.
Unfortunately, I'm not experienced enough in Java to explain it more detailed.

> nodetool doesn't work when Cassandra run with the property 
> java.net.preferIPv6Addresses=true
> --------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-9137
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-9137
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>            Reporter: Andrey Trubachev
>             Fix For: 2.0.15, 2.1.5
>
>         Attachments: cassandra-2.0.14-9137.txt, cassandra-2.1.4-9137.txt
>
>
> nodetool doesn't work when Cassandra run with the property 
> {{java.net.preferIPv6Addresses=true}}.
> {noformat}
> $ sudo netstat -tlpn | grep $(cat /var/run/cassandra/cassandra.pid) | grep 
> 7199
> tcp6       0      0 ::1:7199                :::*                    LISTEN    
>   27560/java
> {noformat}
> {noformat}
> $ nodetool -h ::1 status
> nodetool: Failed to connect to '::1:7199' - ConnectException: 'Connection 
> refused'.
> {noformat}
> Hardcoded value  of the property {{java.rmi.server.hostname}} 
> (https://github.com/apache/cassandra/blob/cassandra-2.1.4/src/java/org/apache/cassandra/service/CassandraDaemon.java#L91)
>  makes RMI returns the address {{127.0.0.1}} instead of {{::1}} that 
> jmxServer listens to.
> {noformat}
> 21:52:26.300192 IP6 (hlim 64, next-header TCP (6) payload length: 259) 
> ::1.7199 > ::1.58706: Flags [P.], cksum 0x010b (incorrect -> 0x6a57), seq 
> 23:250, ack 88, win 2048, options [nop,nop,TS val 1833457 ecr 1833456], 
> length 227
> `......@...................................R.4...../...........
> ........Q....w..SZ.y...L.[....sr..javax.management.remote.rmi.RMIServerImpl_Stub...........pxr..java.rmi.server.RemoteStub......e....pxr..javSZ.y...L.[.....xoteObject.a...a3....pxpw4..UnicastRef2..
>  127.0.0.1...(.L....d
> 21:52:26.336400 IP6 (hlim 64, next-header TCP (6) payload length: 32) 
> ::1.58706 > ::1.7199: Flags [.], cksum 0x0028 (incorrect -> 0xfe1c), seq 88, 
> ack 250, win 2048, options [nop,nop,TS val 1833467 ecr 1833457], length 0
> `.... .@.................................R...../.4.......(.....
> ........
> {noformat}
> jmxServer listens to the an ip address that was resolved from {{localhost}} 
> and it depends on value of the property {{java.net.preferIPv6Addresses}} or 
> lack of it (
> https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/utils/RMIServerSocketFactoryImpl.java#L13).
> This is a simple patch that works correctly with 
> {{java.net.preferIPv6Addresses=(true|false)}} and 
> {{java.net.preferIPv4Stack=(true|false)}}:
> {code}
> diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java 
> b/src/java/org/apache/cassandra/service/CassandraDaemon.java
> index 3e398bf..66e9cca 100644
> --- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
> +++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
> @@ -88,7 +88,7 @@ public class CassandraDaemon
>              }
>              else
>              {
> -                System.setProperty("java.rmi.server.hostname","127.0.0.1");
> +                System.setProperty("java.rmi.server.hostname", 
> InetAddress.getLoopbackAddress().getHostAddress());
>                  try
>                  {
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to