Issues with the Simple-WHIP-Server and VideoRoom

Hello.

I’m trying to get the Simple-WHIP-Server (SWS) up and running dockerized, with the VideoRoom Demo (multistream).

None of the Docker images I found worked, so I created my own. This is the Dockerfile:

FROM ubuntu:20.04

RUN \
    apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get -y install curl g++-10 git nano vim net-tools htop libmicrohttpd-dev libjansson-dev libssl-dev libsofia-sip-ua-dev libglib2.0-dev libopus-dev libogg-dev libcurl4-openssl-dev liblua5.3-dev libconfig-dev pkg-config gengetopt libtool automake python3 python3-pip python3-setuptools python3-dev python3-wheel ninja-build libavcodec-dev libwebsockets-dev && \
    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10

RUN pip3 install meson


WORKDIR /tmp

ENV LIBNICE_VERSION=0.1.18
ENV LIBSRTP_VERSION=v2.4.2
ENV JANUSGATEWAY_VERSION=v1.2.1
ENV CMAKE_VERSION=3.26.4

RUN curl -L -o /tmp/cmake-install.sh https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh \
      && chmod u+x /tmp/cmake-install.sh \
      && mkdir -p /usr \
      && /tmp/cmake-install.sh --skip-license --prefix=/usr \
      && rm /tmp/cmake-install.sh

RUN \
    DIR=/tmp/libnice && \
    mkdir -p ${DIR} && \
    cd ${DIR} && \
    curl -sLf https://github.com/libnice/libnice/archive/${LIBNICE_VERSION}.tar.gz | tar -zx --strip-components=1 && \
    meson --prefix=/usr build/ && \
    ninja -C build && \
    ninja -C build install && \
    rm -rf ${DIR}

RUN \
    DIR=/tmp/libsrtp && \
    mkdir -p ${DIR} && \
    cd ${DIR} && \
    curl -sLf https://github.com/cisco/libsrtp/archive/${LIBSRTP_VERSION}.tar.gz | tar -zx --strip-components=1 && \
    ./configure --prefix=/usr --enable-openssl && \
    make shared_library && \
    make install && \
    rm -rf ${DIR}

RUN \
    DIR=/tmp/janus-gateway && \
    mkdir -p ${DIR} && \
    cd ${DIR} && \
    curl -sLf https://github.com/meetecho/janus-gateway/archive/${JANUSGATEWAY_VERSION}.tar.gz | tar -zx --strip-components=1 && \
    sh autogen.sh && \
    ./configure --prefix=/opt/janus && \
    make && \
    make configs && \
    make install && \
    rm -rf ${DIR}

WORKDIR /app

COPY . /app


# Janus API HTTP
EXPOSE 8088/tcp
# Janus API HTTPS
EXPOSE 8089/tcp
# RTP Media
EXPOSE 20000-20100/udp
# NOTE: Usually we'd want a way larger Media/RTP port range
# but Docker is extremely slow at opening huge port ranges
# (see moby/moby#14288)

CMD exec /opt/janus/bin/janus --rtp-port-range=20000-20100 --nat-1-1=${DOCKER_IP} --configs-folder=/opt/janus/etc/janus

Maybe somebody wants to verify that it’s working and link it instead of the other ones.

Now I have a persistent issue where if more than one stream connects to the server, the connection becomes unstable and streams are disconnected and reconnected all the time.

Any help would be appreciated.

When using Janus on Docker (but any WebRTC server, really), there’s things you should be aware of. We did a presentation on that a few years ago:

1 Like

Yes, I know about the docker issues.
I’ve been using Janus in host mode for a few years now without issues.

I tried setting up Whip with Janus using this docker-compose.yml:

version: '3.9'

services:
  janus-gateway:
    image: janus_ownbuild:latest 
    network_mode: host
    environment:
      - STUN_SERVER=stun.l.google.com
      - STUN_PORT=19302
    container_name: janus-gateway
    volumes:
      - /etc/letsencrypt/live/janus.ourdomain.com/fullchain.pem:/etc/ssl/fullchain.pem
      - /etc/letsencrypt/live/janus.ourdomain.com/privkey.pem:/etc/ssl/privkey.pem
      - ./janus/etc/:/opt/janus/etc/janus
      - ./janus/janus.log:/var/log/janus.log

I call
whip-client -u https://api.janus.ourdomain.com/whip/endpoint/whip1 -V "videotestsrc is-live=true pattern=ball ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay pt=96 ssrc=2 ! queue ! application/x-rtp,media=video,encoding-name=VP8,payload=96" -t "testwhip1" -l 7

Then I get these log outputs:

[WARN] Video offered as 'sendonly', but we need 'inactive' for us: using 'inactive'
[janus] [Wed Feb 28 23:27:40 2024] [ERR] [sdp-utils.c:janus_sdp_get_codec_pt_full:780] Unsupported codec 'none'
[janus] [Wed Feb 28 23:27:40 2024] [WARN] Couldn't find codec we needed (none) in the offer, rejecting video

When I run
whip-client -u https://api.janus.ourdomain.com/whip/endpoint/whip1 -V "filesrc location=/drone.mp4 ! qtdemux ! h264parse ! rtph264pay ! application/x-rtp,media=video,encoding-name=H264,payload=96" -S stun://stun.l.google.com:19302 -t "testwhip1" -l 7

I don’t get an error, I see a WHIP Publisher 1234 in Endpoints, but I get “no remote video available” and as soon as someone else joins the room, WHIP Publisher 1234 gets kicked.

Do we need a WHEP server + client to see the stream in the VideoRoom demo?

You’re doing something wrong with codecs. Probably you’re trying to publish to a room that doesn’t support the codec you configured in the WHIP client, and so video is rejected.

No, you don’t. This is me using the VideoRoom demo to show video pushed via WHIP by OBS:
https://twitter.com/elminiero/status/1615675631123009538

Hi Lorenzo,

I sent you an email with a link to a video yesterday. I realize this is a bit intrusive, but the video contains identifiable data and I didn’t want to post it here.

In this video, I successfully connect one simple-whip-client with a VideoRoom (multistream). When I then connect a second whip-client with a different id to the room, the first one says “Bye!” and the second one claims it’s sending data, but nothing arrives.

I don’t think there’s anything I can do with a video. If you say users are being kicked, you should check what’s happening either at the signalling level (is that user getting a Janus API from the VideoRoom kicking them?) or WebRTC (DTLS alert? ICE disconnection? originated by who?). The latter you can check with tools like wireshark/tcpdump. Looking at the Janus logs may help too.

Hello Lorenzo,

the video shows what happens in Simple Whip Client running 2 streams parrallel.
I followed all the steps you lined out on Github, but I can’t get it to work.

It’s two Simple Whip Client instances connecting to a Simple Whip Server connected to a Janus instance, compiled and run locally – no Docker image – with commands copied directly from the READ.ME.

The streams stop without any visible reason, logging: "[WHIP] GStreamer pipeline stopped, Bye!"
There is no error visible in the Janus log, no Ice error, no DTLS error.

The Janus Admin Api shows this:

"janus": "error",  ~~  "error": {
    "code": 459,
    "reason": "No such handle 315845740987946 in session 7772435643855860"
}

Have you tested the Simple Whip Server with multiple Simple Whip Client streams?

You can’t connect two users to the same WHIP endpoint. You need to create separate WHIP endpoints for concurrent publishers.

Ah nevermind, I think I got what you meant, I just managed to replicate it. I’ll look into it and let you know when there’s a fix :+1:

@Squid I just pushed a fix. The problem was a dumb mistake on my side, as the label was being used as a unique ID in the publishers table, but the label could be the same (e.g., even when autogenerated to WHIP Publisher <room number> if two endpoints are pushing to the same room). With the fix I can’t replicate the problem anymore. Thanks for spotting this!

Thanks, Lorenzo – it works! You’re awesome.

I’m glad I could “help” :smiley: