Comments (1)
Hello, i don't think that Websocket is related to this issue.
A WebRTC session between two peers is splitted into two parts that use two separate communication channels: the handshake, in which the peers exchange their IP addresses and tracks, and the Peer Connection, in which video packets are exchanged.
The handshake can happen with any communication channel of choice (even by exchanging text files through mails), in case of MediaMTX it works by making clients send HTTP requests to the server, and making the server reply with a response (this is WHIP / WHEP). This is the part in which we used to have WebSocket in place of HTTP (although WebSocket is still HTTP-based), but by looking at your logs, the handshake works flawlessly, since clients are able to send requests like:
2024/01/24 14:58:04 DEB [WebRTC] [conn 46.47.28.76:52084] [c->s] POST /path1/whep HTTP/2.0
and the server is able to reply:
2024/01/24 14:58:04 DEB [WebRTC] [conn 46.47.28.76:52084] [s->c] HTTP/1.1 201 Created
The difference between the WHIP/WHEP method and the Websocket-based one is that the latter keeps this communication channel open in order to detect communication losses with the server, and resets the session as soon as this happens. The WHIP/WHEP method is still able to detect communication losses by monitoring the Peer Connection, it's slightly slower but it avoids keeping a direct TCP connection between clients and the server, saving RAM, CPU and bandwidth.
The Peer Connection on the other hand happens through a communication channel that is negotiated during the handshake, but is less flexible. It may be
- a UDP connection
- a TCP connection
- a TCP connection routed through an external TCP server (TURN server)
This has nothing to do with WebSockets or WHIP/WHEP. By looking at your logs, this is the part which fails to initialize and it's because clients and server cannot talk to each other through one of those communication channels, that by default is the UDP one.
There is another difference between v1.5.0 and v0.21.1, and is that former tries to use a fixed UDP port in order to receive requests, while the latter uses a random one. Maybe this issue is caused by the fact that the fixed UDP port you chose is not routed correctly from clients to the server.
Anyway, you can restore the old behavior by setting webrtcLocalUDPAddress
to a blank string, and you have also to use a STUN server:
webrtcLocalUDPAddress: ''
webrtcICEServers2:
- url: stun:stun.l.google.com:19302
If you still have issues, my advice is to follow all steps described in this section of the README:
https://github.com/bluenviron/mediamtx/tree/main?tab=readme-ov-file#connectivity-issues
These describes how to to add IPs, add STUN servers or to try the other two communication methods (TCP and TURN).
from mediamtx.
Related Issues (20)
- Opus channel count is wrongly set in MPEG-TS and fMP4 based protocols HOT 4
- Replace path API endpoint shouldn't error if the path doesn't exist currently
- Allow reading Multichannel Opus streams with WebRTC HOT 7
- Hooks not working (runOnRead,runOnUnread,runOnRecordSegmentCreate,runOnRecordSegmentComplete)
- ffmpeg pull rtsp stream from mediamtx server error HOT 1
- Failed to apply the description for m= section with mid='1': Failed to setup RTCP mux.' HOT 2
- Extra connections when attempting to read an SRT stream with incorrect credentials
- Problem in overriding authInternalUsers configuration HOT 1
- Support streaming H265 over WebRTC HOT 1
- RTMP does not follow standard URL schema so many apps won't accept the URL HOT 1
- docker image has no tzdata so files are saved with incorect timestamps HOT 1
- Hide raspberry pi settings from path API endpoints when the camera isn't an rpi cam HOT 1
- Hide raspberry pi settings from path API endpoints when the camera isn't an rpi cam
- modify config by api wanted HOT 1
- buffer length exceeds 64 HOT 1
- Can't read RTMP source: not enough bytes / Can I push a stream via SRT?
- Make webrtcHandshakeTimeout and webrtcTrackGatherTimeout configurable HOT 2
- Feature Request: Accept German Characters in Camera Path Validation HOT 1
- Feature Request: Accept German Characters in Camera Path Validation HOT 1
- Accept German Characters in Camera Path Validation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mediamtx.