Uploaded image for project: 'Java Couchbase JVM Core'
  1. Java Couchbase JVM Core
  2. JVMCBC-427

Couchbase Java SDK tries to connect to Couchbase via IPv6 addresss when AAAA DNS record exists and "-Djava.net.preferIPv6Addresses=true"

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.3.4
    • 1.4.6
    • None
    • None

    Description

      The Couchbase Java SDK tries to connect to couchbase server via IPv6 address when the following are true:

      • The couchbase server the client is trying to connect to has a AAAA DNS record
      • JVM setting for java.net.preferIPv6Addresses is True

      Since Couchbase server does not support IPv6, it should force ipv4 lookups only (or at least fallback to IPv4) when the IPv6 connection fails. 

       

      Stack trace:

      java.net.ConnectException: Connection refused: ltx1-app1102.stg.linkedin.com/2a04:f547:24:4219:0:0:0:3669:8091
      at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[?:1.8.0_72]
      at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[?:1.8.0_72]
      at com.couchbase.client.deps.io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:224) ~[core-io-1.0.3-LI3.jar:1.0.3-3-g055e252]
      at com.couchbase.client.deps.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:281) ~[core-io-1.0.3-LI3.jar:1.0.3-3-g055e252]
      at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528) ~[core-io-1.0.3-LI3.jar:1.0.3-3-g055e252]
      at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) ~[core-io-1.0.3-LI3.jar:1.0.3-3-g055e252]
      at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) ~[core-io-1.0.3-LI3.jar:1.0.3-3-g055e252]
      at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) ~[core-io-1.0.3-LI3.jar:1.0.3-3-g055e252]
      at com.couchbase.client.deps.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111) ~[core-io-1.0.3-LI3.jar:1.0.3-3-g055e252]
      at com.couchbase.client.deps.io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) ~[core-io-1.0.3-LI3.jar:1.0.3-3-g055e252]

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          Hm, we haven't had this come up before. I assume not setting JVM setting for java.net.preferIPv6Addresses is not an option?

          I need to see how to make this work potentially since we are directing the actual socket openings into netty.

          daschl Michael Nitschinger added a comment - Hm, we haven't had this come up before. I assume not setting JVM setting for java.net.preferIPv6Addresses is not an option? I need to see how to make this work potentially since we are directing the actual socket openings into netty.
          jwon@linkedin.com James Won added a comment -

          Hi Michael! Thanks for responding!

          Unfortunately, as we're turning on IPv6 for our entire datacenter, it is a mandate that java.net.preferIPv6Addresses=true is turned on for all JVMs.

          I think just even adding the functionality to fallback to IPv4 should be more than enough to solve my issue.

           

          Thank you very much!

          jwon@linkedin.com James Won added a comment - Hi Michael! Thanks for responding! Unfortunately, as we're turning on IPv6 for our entire datacenter, it is a mandate that java.net.preferIPv6Addresses=true is turned on for all JVMs. I think just even adding the functionality to fallback to IPv4 should be more than enough to solve my issue.   Thank you very much!

          Right, this is a bit tricky because if java.net.preferIPv6Addresses is enabled I don't think there is a simple way to resolve a hostname to its ipv4 address. (Inet4Address constructors are private) and even Inet4Address.getByName("localhost"); will return the ipv6 addr on getHostAddress.

          I'll see if there is a way to work around it.

          daschl Michael Nitschinger added a comment - Right, this is a bit tricky because if java.net.preferIPv6Addresses is enabled I don't think there is a simple way to resolve a hostname to its ipv4 address. (Inet4Address constructors are private) and even Inet4Address.getByName("localhost"); will return the ipv6 addr on getHostAddress. I'll see if there is a way to work around it.

          I think I got a way to work around this: http://review.couchbase.org/#/c/78393/

          daschl Michael Nitschinger added a comment - I think I got a way to work around this: http://review.couchbase.org/#/c/78393/

          fixed in 1.4.6

          daschl Michael Nitschinger added a comment - fixed in 1.4.6

          People

            daschl Michael Nitschinger
            jwon@linkedin.com James Won
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty