WebRTSP / ReStreamer

Media URLs ReStreamer and Cloud DVR
GNU General Public License v3.0
32 stars 6 forks source link

requesting streams from the ui produce error #40

Closed Ahmed-10 closed 9 months ago

Ahmed-10 commented 10 months ago

** (ReStreamer:1): CRITICAL **: 15:19:09.320: file ../ext/webrtc/gstwebrtcbin.c: line 6001 (gst_webrtc_bin_set_local_description): should not be reached restreamer-bug

[2023-11-29 15:18:54.076] [HttpServer] [debug] Serving "/"...
[2023-11-29 15:18:54.076] [HttpServer] [debug] Routing "/" to "/index.html"...
[2023-11-29 15:18:54.120] [HttpServer] [debug] Serving "/3rd_party/spin-4.1.1.css"...
[2023-11-29 15:18:54.120] [HttpServer] [debug] Serving "/css/WebRTSP.css"...
[2023-11-29 15:18:54.121] [HttpServer] [debug] Serving "/3rd_party/adapter-8.2.1.js"...
[2023-11-29 15:18:54.121] [HttpServer] [debug] Serving "/Config.js"...
[2023-11-29 15:18:54.161] [HttpServer] [debug] Serving "/3rd_party/spin.min-4.1.1.js"...
[2023-11-29 15:18:54.166] [HttpServer] [debug] Serving "/WebRTSP/WebRTSP.mjs"...
[2023-11-29 15:18:54.175] [HttpServer] [debug] Serving "/WebRTSP/RtspMethod.mjs"...
[2023-11-29 15:18:54.175] [HttpServer] [debug] Serving "/WebRTSP/RtspSession.mjs"...
[2023-11-29 15:18:54.175] [HttpServer] [debug] Serving "/WebRTSP/RtspSerialize.mjs"...
[2023-11-29 15:18:54.175] [HttpServer] [debug] Serving "/WebRTSP/RtspParse.mjs"...
[2023-11-29 15:18:54.176] [HttpServer] [debug] Serving "/WebRTSP/RtspStatusCode.mjs"...
[2023-11-29 15:18:54.186] [HttpServer] [debug] Serving "/WebRTSP/RtspProtocol.mjs"...
[2023-11-29 15:18:54.186] [HttpServer] [debug] Serving "/WebRTSP/Token.mjs"...
[2023-11-29 15:18:54.186] [HttpServer] [debug] Serving "/WebRTSP/ParseBuffer.mjs"...
[2023-11-29 15:18:54.187] [HttpServer] [debug] Serving "/WebRTSP/RtspRequest.mjs"...
[2023-11-29 15:18:54.193] [HttpServer] [debug] Serving "/WebRTSP/RtspResponse.mjs"...
[2023-11-29 15:18:54.250] [WsServer] [info] Got DESCRIBE request for "6535362bc97bc9002bf88bef"
[2023-11-29 15:18:55.512] [WsServer] [info] Got PLAY request for "6535362bc97bc9002bf88bef"
[2023-11-29 15:18:56.560] [GstRtStreaming] [debug] [GstWebRTCPeerBase] Signaling State changed: "GST_WEBRTC_SIGNALING_STATE_HAVE_LOCAL_OFFER"
[2023-11-29 15:18:56.561] [GstRtStreaming] [debug] [GstWebRTCPeerBase] Signaling State changed: "GST_WEBRTC_SIGNALING_STATE_STABLE"
[2023-11-29 15:18:56.594] [GstRtStreaming] [debug] [GstWebRTCPeerBase] Ice Connection State changed: "GST_WEBRTC_ICE_CONNECTION_STATE_CHECKING"
[2023-11-29 15:18:56.594] [GstRtStreaming] [debug] [GstWebRTCPeerBase] Connection State changed: "GST_WEBRTC_PEER_CONNECTION_STATE_CONNECTING"
[2023-11-29 15:18:56.654] [GstRtStreaming] [debug] [GstWebRTCPeerBase] Selected ICE Pair: Local "host 192.168.0.121 UDP" - Remote "host 192.168.0.121 UDP"
[2023-11-29 15:18:56.655] [GstRtStreaming] [debug] [GstWebRTCPeerBase] Ice Connection State changed: "GST_WEBRTC_ICE_CONNECTION_STATE_CONNECTED"
[2023-11-29 15:18:56.655] [GstRtStreaming] [debug] [GstWebRTCPeerBase] Ice Connection State changed: "GST_WEBRTC_ICE_CONNECTION_STATE_COMPLETED"
[2023-11-29 15:18:56.664] [GstRtStreaming] [debug] [GstWebRTCPeerBase] Connection State changed: "GST_WEBRTC_PEER_CONNECTION_STATE_CONNECTED"
[2023-11-29 15:19:02.546] [HttpServer] [debug] Serving "/3rd_party/spin-4.1.1.css"...
[2023-11-29 15:19:02.547] [HttpServer] [debug] Serving "/css/WebRTSP.css"...
[2023-11-29 15:19:06.999] [GstRtStreaming] [debug] Teardown peer...
[2023-11-29 15:19:07.021] [WsServer] [info] Got DESCRIBE request for "6535139ec97bc9002bf88be7"
[2023-11-29 15:19:07.683] [WsServer] [info] Got DESCRIBE request for "6535350fc97bc9004ff88bf3"
[2023-11-29 15:19:08.267] [WsServer] [info] Got DESCRIBE request for "6535355bc97bc9004ff88bf6"
[2023-11-29 15:19:08.400] [WsServer] [info] Got PLAY request for "6535355bc97bc9004ff88bf6"
[2023-11-29 15:19:08.717] [GstRtStreaming] [debug] Teardown peer...

** (ReStreamer:1): CRITICAL **: 15:19:09.320: file ../ext/webrtc/gstwebrtcbin.c: line 6001 (gst_webrtc_bin_set_local_description): should not be reached
RSATom commented 10 months ago

@Ahmed-10 what type of source you are trying to play?

RSATom commented 10 months ago

also, are you trying to run it from Snap package or you've built it from sources yourself?

Ahmed-10 commented 10 months ago

I was building from source in docker container after adding the h264 streams from RTSP cameras in my network to the restreamer.conf

Ahmed-10 commented 10 months ago
FROM ubuntu:22.04
ENV TZ=Africa
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app

RUN apt update 
RUN apt install -y build-essential cmake git
RUN apt-get install -y libspdlog-dev libconfig-dev libssl-dev libgstreamer1.0-0 libgstreamer1.0-dev \
    libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
    gstreamer1.0-nice libnice-dev 
# gstreamer cli 
RUN apt install gstreamer1.0-tools

RUN git clone https://github.com/warmcat/libwebsockets.git --branch v4.2-stable --depth 1
RUN cmake -B build -S libwebsockets -DLWS_WITH_GLIB=ON
RUN cmake --build ./build
RUN cmake --install ./build

RUN rm -rf libwebsockets
RUN rm -rf build
RUN apt update
RUN apt install -y gsoap libgsoap-dev libmicrohttpd-dev
COPY . .
RUN cmake -B build
RUN cmake --build ./build
RUN mv ./restreamer.conf.sample /etc/xdg/restreamer.conf
RUN ldconfig
CMD ["./build/ReStreamer"]
Ahmed-10 commented 10 months ago

I had 2 web clients running. both repeated switching streams quickly and that it works for a couple of clicks then it crashes

RSATom commented 10 months ago

@Ahmed-10 can you please try the same rtsp source with snap package from edge channel? I want be sure issue is not related to your GStreamer version.

Ahmed-10 commented 10 months ago

installed using snap on ubuntu 22.04 Screenshot from 2023-11-30 13-26-04 after a couple of clicks and switching between streams. a message repeatedly printed to the console

WebRTSP.mjs:65 Failed to handle message:
TEARDOWN Konsk%C3%BD%20Gr%C3%BA%C5%88 WEBRTSP/0.2
CSeq: 1
Session: 1

Disconnecting...

and at the end I got a disconnected message

Ahmed-10 commented 10 months ago

Screenshot from 2023-11-30 14-04-40

RSATom commented 10 months ago

It's known minor issue in browser client. The main question is if ReStreamer itself crashing or not. Please try viewing logs with 'sudo snap logs rtsp-to-webrtsp -f'

Ahmed-10 commented 10 months ago

here are the logs from sudo snap logs rtsp-to-webrtsp -f restreamer-snap-bug.txt

2023-11-30T17:25:33+02:00 -[783861]: file ../src/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c: line 6759 (gst_webrtc_bin_set_local_description): should not be reached
2023-11-30T17:25:33+02:00 systemd[1]: snap.rtsp-to-webrtsp.ReStreamer.service: Main process exited, code=killed, status=11/SEGV
2023-11-30T17:25:33+02:00 systemd[1]: snap.rtsp-to-webrtsp.ReStreamer.service: Failed with result 'signal'.
2023-11-30T17:25:34+02:00 systemd[1]: snap.rtsp-to-webrtsp.ReStreamer.service: Scheduled restart job, restart counter is at 2.
2023-11-30T17:25:34+02:00 systemd[1]: Stopped Service for snap application rtsp-to-webrtsp.ReStreamer.
2023-11-30T17:25:34+02:00 systemd[1]: Started Service for snap application rtsp-to-webrtsp.ReStreamer.

the same error happened in the docker file you can find it in the logs file lines 295 and 1692 it was harder to catch as the snap restarts the process very quickly

RSATom commented 10 months ago

Thanks! it's good starting point. Did you use predefined demo sources or your own sources?

Ahmed-10 commented 10 months ago

I used my resources. h264 streams from RTSP cameras in my local network

RSATom commented 10 months ago

Are you able to reproduce issue with demo sources?

Ahmed-10 commented 10 months ago

I failed to reproduce the error with the demo sources. however, I use RTSP streams from commercial cameras: Bosch DINION IP starlight 6000i IR, Hikvision DS-2CD4165F-IZ, Hikvision DS-2CD2623G0-IZS, AXIS P1427-E, AXIS P1377-LE, AXIS Q1700-LE, AVIGILON 1.0MP Day/Night H.264 HD.

RSATom commented 10 months ago

Ok, I'll try tor reproduce issue myself with cams I have... thanks!

RSATom commented 10 months ago

@Ahmed-10 I think I've fixed crash but I'm still not sure I've fixed your initial issue. Please try.

Ahmed-10 commented 10 months ago

the crash causing the application to terminate is fixed. However, the problem with the switching between streams is still on but now it's different. the websocket connection is closed from the websocket server. and the client is unable to connect again. Screenshot from 2023-12-04 11-05-35 the last printed logs from the terminal image

RSATom commented 10 months ago

@Ahmed-10 does it work if don't do quick switch between sources?

Ahmed-10 commented 10 months ago

yes, but when multiple clients connect to the WebSocket server. it produces the same problem, which is initially the case.

RSATom commented 10 months ago

So we can be sure your IP Cams provide compatible video stream... Ok, I'll try to reproduce issue. Thanks!

RSATom commented 10 months ago

@Ahmed-10 unfortunately I was not able to reproduce issue with 2 cams attached: first - some cheep Chinese cam, second - AXIS M5014 cam. Both was connected over rtsp.

So I need your assistance:

  1. how many cams you have to use to reproduce issue?
  2. did you connect your cams with rtsp or with ONVIF?
  3. can you please try reproduce issue with the latest snap package?
  4. it could be useful to see logs with increased logs level to 5:
    debug: {
    log-level: 5
    }

    if you don't want to share possible private info from logs - you may send logs directly to my email.

RSATom commented 10 months ago

@Ahmed-10 ping

Ahmed-10 commented 10 months ago

1- number of cams: 8 2- all connections were over RTSP. I didn't use ONVIF. 3- I couldn't reproduce the error with the latest snap package (logs are sent to your email) 4- I increased the log-level to 5 (logs are sent to your email)

RSATom commented 10 months ago

@Ahmed-10 the most obvious difference I can see - you are using libwebsockets v4.2, but snap users v4.3. I don't know if it's related to your issue, but I would recommend you switch to v4.3. On my side I'll try to use v4.2 to reproduce issue...

RSATom commented 10 months ago

@Ahmed-10 Tried to reproduce with libwebsockets v4.2 - no luck. So it's something different. For example snap is based on GStreamer v1.22... So I would recommend you try build Docker the same way like it was done in Snap build script On my side now I'm going to try build docker image myself and try it...

RSATom commented 9 months ago

@Ahmed-10 tried to test your Dockerfile - didn't get any issue... It looks like you do something different comparing to me - and it's required to understand what exactly....

Can you please tell, can you reproduce issue with demo urls and your Dockerfile?

Ahmed-10 commented 9 months ago

the issue is only produced with RTSP links with the same network. running against the Dockerfile I sent you. I'm trying to build an image with the snap dependency and I will update you with the result

RSATom commented 9 months ago

I'm not sure if it's possible to put snap into Docker also I'm not sure it's good idea...

Anyway, please do following with your docker build:

  1. set following in config
    debug: {
    log-level: 5
    lws-log-level: 5
    }
  2. update libwebsockets to v4.3
  3. build, run and try reproduce issue and send me logs
Ahmed-10 commented 9 months ago

@Ahmed-10 Tried to reproduce with libwebsockets v4.2 - no luck. So it's something different. For example snap is based on GStreamer v1.22... So I would recommend you try build Docker the same way like it was done in Snap build script On my side now I'm going to try build docker image myself and try it...

I didn't mean to install snap into docker. what I meant is to install gstreamer 1.22 from source with the same customization from the snap build script. and it worked well without crashes.

surprisingly when installing gstreamer 1.22 from apt on ubuntu 23.04 the crash occurs. but I'm happy that the build from source solved my issue.

Thank you for your help.