Skip to content

IPv6 Support for broker and proxy with bindAddress #14732

Closed

Description

@0asys

Describe the bug
the default setting for binding in broker.conf and proxy.conf is bindAddress=0.0.0.0.

bindAddress=0.0.0.0

the specified default 0.0.0.0 binds to ipv4 only, so the service is not reachable over ipv6.

[root@proxy pulsar]# netstat -tulpen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name
tcp        0      0 0.0.0.0:6650            0.0.0.0:*               LISTEN      41186      8351118    2470721/java
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      41186      8349589    2470721/java

this setting does not accept a a ipv6 address [::0], ::0 or a ipv6 address with or without brackets.

available error in logs:

2022-03-17T10:52:55,986+0100 [sun.misc.Launcher$AppClassLoader@1d56ce6a] error Uncaught exception in thread main: Failed to bind Pulsar Proxy on port 6650

To Reproduce
Steps to reproduce the behavior:

  1. Set a ipv6 address in broker.conf or proxy.conf for bindAdress: bindAddress=[::0]
  2. restart pulsar broker or proxy
  3. check listening ports - no pulsar listen on ::6650

Expected behavior
pulsar broker and proxy listens on ipv6 address.

Desktop (please complete the following information):

  • OS: RedHat 8
  • Pulsar v2.9.1

Additional context

Activity

  1. added
    type/bug
    on Mar 17, 2022
  2. eolivelli commented on Mar 17, 2022

    @eolivelli
    Contributor

    are you able to troubleshot why this is happening ?
    like putting some debug

  3. 0asys commented on Mar 17, 2022

    @0asys
    ContributorAuthor

    unfortunately, setting log levels to debug with env vars:

    PULSAR_LOG_LEVEL=debug
    PULSAR_LOG_ROOT_LEVEL=debug
    

    does show debug logs, but no additional errors or hints for this specific problem.

    is jetty used for this?
    the default bind address is set to 0.0.0.0 in the codebase:

    and there is a jetty discussion, if the bind address is not defined, both stacks (4 & 6) are considered by default:
    https://www.eclipse.org/lists/jetty-users/msg09643.html

  4. eolivelli commented on Mar 17, 2022

    @eolivelli
    Contributor

    we are using Jetty for the REST API part and Netty for the Binary part

  5. 0asys commented on Mar 17, 2022

    @0asys
    ContributorAuthor

    error originating from:

    throw new IOException("Failed to bind Pulsar Proxy on port " + proxyConfig.getServicePort().get(), e);

    I think this is the relevant part for binding in netty:
    https://github.com/netty/netty/blob/d34212439068091bcec29a8fad4df82f0a82c638/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java#L252

    references here for the properties, where lobmok is used:

    convert with SocketUtils.socketAddress string to InetSocketAddress:
    https://github.com/netty/netty/blob/40382fb1af275e931a765c5001f4b6bd8061991e/common/src/main/java/io/netty/util/internal/SocketUtils.java#L177

    but i don't see the thrown exception somewhere in the output or log, but there should be one from the thrown IOException

  6. eolivelli commented on Mar 17, 2022

    @eolivelli
    Contributor

    if I remove all the occurrences of "-Djava.net.preferIPv4Stack=true" inside "bin" (or you can set it to "false") then I am able to boot Pulsar standalone and the proxy on my Mac with JDK11

  7. 0asys commented on Mar 17, 2022

    @0asys
    ContributorAuthor

    jup, this works.

    set bindAddress=0.0.0.0 in proxy.conf and removing -Djava.net.preferIPv4Stack=true in bin/pulsar is indeed working.

    why is the setting java.net.preferIPv4Stack even in place? Should this not be as the default (false) and enabling dualstack?
    IMHO this should be standard today.

  8. eolivelli commented on Mar 17, 2022

    @eolivelli
    Contributor

    I believe that it is only because support for IPV6 is not fully available in many libraries (like parsing addresses..) and no one dares to enable it.

    If you are able to successfully run all Pulsar components without issues, then please advertise on user@pulsar or dev@pulsar and we can remove that flag, or make it configurable somehow.

  9. wangjialing218 commented on Mar 18, 2022

    @wangjialing218
    Contributor

    I have already test IPV6 connections between pulasr client and broker, as long as kafka client and kop, with -Djava.net.preferIPv4Stack=false, there seems no problem.
    And I'm going to have a IPV6 test between broker and bookie and zookeeper, after than we could make it default false.

  10. 6 remaining items

  11. github-actions commented on May 23, 2022

    @github-actions

    The issue had no activity for 30 days, mark with Stale label.

  12. github-actions commented on Jun 22, 2022

    @github-actions

    The issue had no activity for 30 days, mark with Stale label.

  13. 0asys commented on Jun 28, 2022

    @0asys
    ContributorAuthor

    /remove stale

  14. github-actions commented on Jul 29, 2022

    @github-actions

    The issue had no activity for 30 days, mark with Stale label.

  15. MarvinCai commented on Aug 1, 2022

    @MarvinCai
    Contributor

    hi @bpereto, are you expecting any additional changes in Pulsar to support ipv6?
    As Enrico mentioned, we added -Djava.net.preferIPv4Stack=true as most users are still using ipv4. And to override this behavior without change the ./bin/pulsar script we can add env variable export PULSAR_EXTRA_OPTS=-Djava.net.preferIPv4Stack=false, this should be able to override the the default setting.

  16. 0asys commented on Aug 1, 2022

    @0asys
    ContributorAuthor

    Hi @MarvinCai,

    We are currently on 2.9 and did not test the available refactor in master (58ad467).

    An available ENV variable as you suggesting would be nice, also to support adoption.

  17. 0asys commented on Aug 12, 2024

    @0asys
    ContributorAuthor

    tested with

    • pulsar 3.0.5 LTS
    • jdk 17
    • PULSAR_EXTRA_OPTS=-Djava.net.preferIPv4Stack=false
    • BOOKIE_EXTRA_OPTS=-Djava.net.preferIPv4Stack=false

    and seems to work so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/staletype/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions