Ec2 Instance running docker+ros2: unable to join

I am running a docker container on ec2 which runs ros2 humble and husarnet with cyclone dds. The container starts up fine, however it is never able to join the server, and therefore the listener node cannot receive any incoming data.

On ec2, I’ve opened up UDP ports 5582 - 5583 for ipv4 and ipv6, as well as TCP port 443 for ipv4/ipv6 communication inbound. All outbound udp/tcp communication is open as well.

What can I do to debug why the docker container cannot join the husarnet group? Do I need to remove specific firewalls/open up different ports? Do I need to just clear out docker/husarnet and startover?


When running locally within the ec2 container (and not also in the docker container), I can join the husarnet account with a device fine.

My docker compose file is:

version: '2.3'

services:
    robot_listener:
        build:
            context: ../..
            dockerfile: my_container/robot_listener/Dockerfile

        command: ros2 launch emulator robot_listener_launch.py
        network_mode: service:husarnet

        depends_on:
            husarnet: { condition: service_healthy }

    husarnet:
        image: husarnet/husarnet
        restart: unless-stopped
        volumes:
            # This will persist your Husarnet Client keys, thus IP of the container will be stable/the same between (re)boots
            - /var/lib/husarnet
        sysctls:
            # Husarnet is using IPv6 for the internal connections
            - net.ipv6.conf.all.disable_ipv6=0
        cap_add:
            - NET_ADMIN
        devices:
            - /dev/net/tun
        environment:
            - JOINCODE=MY_JOIN_CODE
            - HOSTNAME=robot-listener
            - HUSARNET_DEBUG=1

My cyclonedds config file is:

<?xml version="1.0" encoding="UTF-8" ?>
<CycloneDDS xmlns="https://cdds.io/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://cdds.io/config https://raw.githubusercontent.com/eclipse-cyclonedds/cyclonedds/master/etc/cyclonedds.xsd">
    <Domain id="any">
        <General>
            <NetworkInterfaceAddress>hnet0</NetworkInterfaceAddress>
            <AllowMulticast>false</AllowMulticast>
            <MaxMessageSize>8388608B</MaxMessageSize> <!-- 8MB -->
            <FragmentSize>32000B</FragmentSize> <!-- 16KB -->
            <Transport>udp6</Transport>
        </General>
        <Discovery>
            <ParticipantIndex>auto</ParticipantIndex>
            <MaxAutoParticipantIndex>100</MaxAutoParticipantIndex>
        </Discovery>
        <Internal>
            <Watermarks>
                <WhcHigh>1MB</WhcHigh>
            </Watermarks>
            <SocketReceiveBufferSize min="10MB"/>
        </Internal>
        <Tracing>
            <Verbosity>fine</Verbosity>
            <OutputFile>stdout</OutputFile>
        </Tracing>
    </Domain>
</CycloneDDS>

It’s also worth noting that this docker container can communicate fine with the other ros2+docker+husarnet container when they’re both running locally with the same husarnet cyclonedds configuration file.

Hi @kobra

Try following command:

ufw allow in on hnet0 from fc94::/16

You may also need to add similar rule in ec2 firewall.

Make sure ports UDP 5582 and TCP 443 are open in ufw too, not just in ec2 firewall.

Regards, Filip