paullouisageneau / libdatachannel

C/C++ WebRTC network library featuring Data Channels, Media Transport, and WebSockets
https://libdatachannel.org/
Mozilla Public License 2.0
1.8k stars 361 forks source link

`juice: Send failed, buffer is full` error in media-sender example #1108

Open BlueCannonBall opened 9 months ago

BlueCannonBall commented 9 months ago

I'm trying to use the media-sender example to send my screen to another device on my network. I am using this command to do this: gst-launch-1.0 ximagesrc startx=0 use-damage=0 ! video/x-raw,width=1366,height=768,framerate=60/1 ! videoconvert ! queue ! x264enc tune=zerolatency speed-preset=ultrafast bitrate=3000 ! video/x-h264, profile=baseline ! rtph264pay pt=96 mtu=1200 ! udpsink host=0.0.0.0 port=6000 However, upon connecting, media-sender starts spamming a message saying "Send failed, buffer is full." Another issue on this repo claims that this error means that this error indicates that the network simply cannot handle the amount of data being sent, but I don't think this is the case. I can use gst-launch-1.0 udpsrc address=0.0.0.0 port=6000 caps="application/x-rtp" ! queue ! rtph264depay ! video/x-h264,stream-format=byte-stream ! avdec_h264 ! autovideosink on the other device to receive and display the screen, and the performance is excellent and latency is low.

paullouisageneau commented 9 months ago

The warning means either you are sending faster than the network link can handle or the system maximum UDP socket buffer size is too small to contain a single frame. Since you are sending at a rather low bitrate here, it's probably the latter.

On Linux, you can increase the maximum socket buffer size with:

$ sudo sysctl -w net.core.wmem_max=1048576
$ sudo sysctl -w net.core.rmem_max=1048576

The change can be made persistent in /etc/sysctl.conf.

BlueCannonBall commented 8 months ago

Running that didn't help. I don't think the issue is at that level, because as I said before, I can use GStreamer's udpsrc to view the screen without any problems.

paullouisageneau commented 8 months ago

Running that didn't help.

Did you run it on the sender host before starting the media-sender?

I don't think the issue is at that level, because as I said before, I can use GStreamer's udpsrc to view the screen without any problems.

The warning specifically means that a packet is dropped because the socket buffer is full. It can be explained only by a too small socket buffer or sending over link capacity. The stream might still be fine as the decoder is tolerant to losses.

BlueCannonBall commented 8 months ago

Did you run it on the sender host before starting the media-sender?

Yes. Should I try running it on the receiving side as well?

paullouisageneau commented 8 months ago

Yes. Should I try running it on the receiving side as well?

No, setting it on sender should be sufficient. What is your network setup?

By the way, udpsink in your pipeline has host=0.0.0.0, whereas it should be host=127.0.0.1. 0.0.0.0 would literally mean "broadcast to any address" and you don't want to do that (it should still send to localhost in that case but you never know).