How to connect to sctp server running in docker container from the sctp client on host machine?

My host machine application is trying to establish a SCTP connection at port 38412 to a docker container which is running SCTP server at port 38412. I am mapping and publishing the ports but getting an error. My host application is timing out at the following check:

if (connect(fd, (struct sockaddr*)&myaddr,sizeof(myaddr))== -1){
	higLog("SCTP CLIENT connect failed, port %d, Error %s",
		port, strerror(errno));
	return -1;
}

Error Connection timed out

My DockerFile looks something like this.

FROM ubuntu:focal

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
	apt-get install -y \
    dialog \
    apt-utils \
    iputils-ping \
    inetutils-traceroute \
    iproute2 \
    curl \
    dnsutils \
    nano \
    build-essential \
    libcpprest-dev \
    libboost-all-dev \
    libssl-dev \
    cmake \
    libyaml-cpp-dev \
    libsctp1 \
    libsctp-dev \
    tre-agrep \
    libtre5 \
    libtre-dev \
    libhiredis-dev \
    gcovr \
    lcov \
    curl \
    make \
    binutils \
    libcurlpp-dev \
    libcurlpp0 \
    libjsoncpp-dev

COPY . $HOME/src/D1/Func
RUN cd src
RUN mkdir utility_library
RUN cd ..
RUN mv src/D1/Func/utility_library src/utility_library
WORKDIR "$HOME/src/D1/Func"
EXPOSE 80
CMD ["/bin/bash", "-c", "cmake .;make -j16;./build/bin/Func eth0"]

And running this container using the following docker-run command:

docker run --name con1 --net Network1 --ip 10.0.0.21 -p 127.0.0.1:38412:38412/sctp sourav/image1:1.0.0

Can I get some ideas on how to solve it ?

did you get any success? im in the same situation (opposite direction, server is in the network and i need to connect to the server from a container)

Same port no. mapping doesn’t work with sctp. Try different port no. for the container and host for the mapping. This change helped in solving my issue.

1 Like