Closed VanderBieu closed 6 months ago
What client-side streaming software are you using? If using OBS please provide the version number.
What client-side streaming software are you using? If using OBS please provide the version number.
I was using OBS v30.0.2, Apple Silicon build.
Hi @VanderBieu @EnergoStalin Please try the latest code from the master branch.
I encountered almost the same error yesterday and after that I also tried working with just webrtc-rs. Interestingly, although I did not make any changes to the code I had run before, webrtc-rs/broadcast_example stopped working, giving almost the same error.
A very similar situation occurred in your old code, but I cannot send its logs right now. In the current version of xiu, we encounter the following error (tried to start streaming 3 times):
[2023-12-23T23:58:19Z INFO xwebrtc::webrtc] WebRTC server listening on tcp://0.0.0.0:8900
[2023-12-23T23:58:19Z INFO rtmp::rtmp] Rtmp server listening on tcp://0.0.0.0:1935
[2023-12-23T23:58:19Z INFO xiu::api] Http api server listening on http://:8080
[2023-12-23T23:59:23Z ERROR xwebrtc::webrtc] session run error, err: Utf8Error: invalid utf-8 sequence of 1 bytes from index 17
[2023-12-24T00:01:16Z ERROR xwebrtc::webrtc] session run error, err: Utf8Error: invalid utf-8 sequence of 2 bytes from index 3
[2023-12-24T00:01:23Z ERROR xwebrtc::webrtc] session run error, err: Utf8Error: invalid utf-8 sequence of 1 bytes from index 17
The streaming software I used when testing xiu is obs@30.0.2 for windows. Also the servers are running on WSL (Default Distribution: Ubuntu-22.04 Default Version: 2).
I will try it on a virtual server soon and investigate the source of the problem. There seems to be a completely different error in the current version of xiu. As for the error related to webrtc, my guess is that it may be related to the mdns or stun connection, but it is difficult to say anything without examining the network records in detail, maybe it would be useful to consult the developers of webrtc-rs.
edit: i tried webrtc-rs's broadcast example over and over again and managed to get a delayed response on one, when I typed base64 encoded sdp that the server wrote to the console in jsfiddle the connection was established.
@ikircik thanks for your detailed descriptions for the problem, I conducted some test on a local network where I used OBS (v30.0.2) on one Mac to stream to Xiu Server on another one. Below are some logs:
2023-12-24T03:36:14Z INFO xwebrtc::webrtc] WebRTC server listening on tcp://0.0.0.0:8900
2023-12-24T03:36:14Z INFO xiu::api] Http api server listening on http://:8000
2023-12-24T03:36:17Z INFO xwebrtc::session] 1:whip,2:live,3:test
2023-12-24T03:36:17Z INFO streamhub] event data: {"Publish":{"identifier":{"WebRTC":{"app_name":"live","stream_name":"test"}},"info":{"id":"1703388977", sub_type":"PushWebRTC","notify_info":{"request_url":"","remote_addr":""}}}}
2023-12-24T03:36:17Z INFO streamhub] transmiter exits: idetifier: WebRTC - app_name: live, stream_name: test
2023-12-24T03:36:17Z INFO webrtc::peer_connection] signaling state changed to have-remote-offer
2023-12-24T03:36:17Z INFO webrtc_ice::mdns] mDNS is using 0.0.0.0:5353 as dest_addr
2023-12-24T03:36:17Z INFO webrtc_mdns::conn] Looping and listening Ok(0.0.0.0:5353)
2023-12-24T03:36:17Z INFO webrtc::peer_connection] signaling state changed to stable
2023-12-24T03:36:17Z INFO webrtc_ice::agent::agent_internal] [controlled]: Setting new connection state: Checking
2023-12-24T03:36:17Z WARN webrtc_ice::agent::agent_internal] [controlled]: pingAllCandidates called with no candidate pairs. Connection is not possible et.
2023-12-24T03:36:17Z INFO webrtc::peer_connection] ICE connection state changed: checking
2023-12-24T03:36:17Z INFO xwebrtc::whip] Connection State has changed checking
2023-12-24T03:36:17Z WARN webrtc_ice::agent::agent_internal] [controlled]: pingAllCandidates called with no candidate pairs. Connection is not possible et.
2023-12-24T03:36:17Z WARN webrtc_ice::agent::agent_gather] [controlled]: could not listen udp fe:80::: io error: Can't assign requested address (os rror 49)
2023-12-24T03:36:17Z WARN webrtc_ice::agent::agent_gather] [controlled]: failed to resolve stun host: stun.l.google.com:19302: io error: No available pv6 IP address found!
2023-12-24T03:36:19Z INFO webrtc_ice::agent::agent_internal] [controlled]: Setting new connection state: Connected
2023-12-24T03:36:19Z INFO webrtc::peer_connection] ICE connection state changed: connected
2023-12-24T03:36:19Z INFO xwebrtc::whip] Connection State has changed connected
2023-12-24T03:36:19Z INFO xwebrtc::whip] Ctrl+C the remote client to stop the demo
2023-12-24T03:36:19Z INFO webrtc::peer_connection] peer connection state changed: connected
2023-12-24T03:36:19Z INFO xwebrtc::whip] Peer Connection State has changed: connected
including some warnings, but they didn't affect the successful streaming. The error logs you mentioned are new to me, I'll also do some investigate ..
Hi @ikircik I cannot reproduce, according to your logs I suspect that the error log was generated by this line of code:
if let Some(http_request) = HttpRequest::unmarshal(std::str::from_utf8(&request_data)?) {
or maybe this line:
std::str::from_utf8(&request_data)?
If that's the case, it could be related to an issue with the HTTP request.
First of all, I owe you a big apology. While trying yesterday, I made the OBS settings wrong and chose the "custom" option instead of "whip", this was the reason for the errors related to utf8.
What draws my attention here is that the IP addresses in the logs always belong to the "private network". For example, fd... for ipv6 in the first comment, 192...,169...,172... for ipv4 in this comment. I now have a serious suspicion that this might be related to the network configuration on WSL, but I cannot understand the situation of the other commenters. I hope to try it on VM during the day and share the results.
Finally, I created an ubuntu@22.04.3-desktop virtual machine with hyperv and ran a few tests using obs@30.0.2 on windows.
Again, it seems that the stream cannot be started when WHIP used. Then, I'm trying to start a stream using RTMP to test WHEP.
_There seems to be a minor problem with RTMP (When we do rtmp://ip:port/appname/streamname, stream_name appears empty and all parameters are set to app_name.), I noticed that streamname is taken from stream key.
but WHEP is definitely not working at all.
Additionally, I tried to connect to STUN servers separately and there were no problems.
I also tried the webrtc-rs broadcast example in the vm in the previous comment and I was able to manually transfer the base64encoded sdp (as in readme) and start streaming.
Unfortunately, I must also say that the results of the tests I repeated several times are not consistent. Sometimes the writing of the sdp string is extremely delayed and in this case the connection cannot be established and is closed. I actually experienced this a few times when my internet connection was extremely bad. From what I observed, this was happening more especially in WSL. However, even in an ideal connection situation, I couldn't get close to this with xiu. Despite my many efforts, I have not been able to create any successful streams yet. I am sorry that I did not fully understand the problem and therefore could not explain it. I will try to detect the problem by making a few changes to the xiu codes when I am free.
It was CORS problem in my case.
I wonder wether it should be handled by xiu or it should be put behind proxy.
But i still cant ingest stream through whep.js page no errors in logs tho.
Can see only black screen on whep page despide having successful screenshare in VDO ninja. Now i'm unsure what's wrong again.
Finally, I created an ubuntu@22.04.3-desktop virtual machine with hyperv and ran a few tests using obs@30.0.2 on windows.
xiu logs: As soon as I saw the connection error box in obs, I tried to start the stream again and the beginning of the second request was separated by ----.
[2023-12-24T12:20:50Z INFO xwebrtc::webrtc] WebRTC server listening on tcp://0.0.0.0:8900 [2023-12-24T12:20:50Z INFO xiu::api] Http api server listening on http://:8080 [2023-12-24T12:20:50Z INFO rtmp::rtmp] Rtmp server listening on tcp://0.0.0.0:1935 [2023-12-24T12:22:08Z INFO xwebrtc::session] 1:whip,2:live,3:test [2023-12-24T12:22:08Z INFO streamhub] event data: {"Publish":{"identifier":{"WebRTC":{"app_name":"live","stream_name":"test"}},"info":{"id":"1703420528","sub_type":"PushWebRTC","notify_info":{"request_url":"","remote_addr":""}}}} [2023-12-24T12:22:08Z INFO streamhub] transmiter exits: idetifier: WebRTC - app_name: live, stream_name: test [2023-12-24T12:22:08Z INFO webrtc::peer_connection] signaling state changed to have-remote-offer [2023-12-24T12:22:08Z INFO webrtc_ice::mdns] mDNS is using 224.0.0.251:5353 as dest_addr [2023-12-24T12:22:08Z INFO webrtc_mdns::conn] Looping and listening Ok(224.0.0.251:5353) [2023-12-24T12:22:08Z INFO webrtc::peer_connection] signaling state changed to stable [2023-12-24T12:22:08Z WARN webrtc_ice::agent::agent_gather] [controlled]: could not listen udp fe:80::: io error: Cannot assign requested address (os error 99) [2023-12-24T12:22:08Z DEBUG webrtc_ice::agent::agent_internal] Started agent: isControlling? false, remoteUfrag: sD70, remotePwd: eQ0h4oftbfmBy0HMr8Lc4E [2023-12-24T12:22:08Z INFO webrtc_ice::agent::agent_internal] [controlled]: Setting new connection state: Checking [2023-12-24T12:22:08Z INFO webrtc::peer_connection] ICE connection state changed: checking [2023-12-24T12:22:08Z INFO xwebrtc::whip] Connection State has changed checking [2023-12-24T12:22:08Z WARN webrtc_ice::agent::agent_gather] [controlled]: could not get server reflexive address udp6 stun:stun.l.google.com:19302: io error: Network is unreachable (os error 101) [2023-12-24T12:22:38Z WARN webrtc_ice::agent::agent_internal] [controlled]: Failed to close candidate udp4 host 172.21.128.1:53403: the agent is closed [2023-12-24T12:22:38Z WARN webrtc_ice::agent::agent_internal] [controlled]: Failed to close candidate udp4 host 172.22.160.1:53403: the agent is closed [2023-12-24T12:22:38Z WARN webrtc_ice::agent::agent_internal] [controlled]: Failed to close candidate udp4 host 192.168.124.30:53403: the agent is closed [2023-12-24T12:22:38Z WARN webrtc_ice::agent::agent_internal] [controlled]: Failed to close candidate udp4 host 172.31.16.1:53403: the agent is closed [2023-12-24T12:22:38Z WARN webrtc_ice::agent::agent_internal] [controlled]: Failed to close candidate udp4 host 172.22.192.1:53403: the agent is closed [2023-12-24T12:22:38Z INFO webrtc_ice::agent::agent_internal] [controlled]: Setting new connection state: Failed [2023-12-24T12:22:38Z INFO webrtc::peer_connection] ICE connection state changed: failed [2023-12-24T12:22:38Z INFO xwebrtc::whip] Connection State has changed failed [2023-12-24T12:22:38Z INFO webrtc::peer_connection] peer connection state changed: failed [2023-12-24T12:22:38Z INFO xwebrtc::whip] Peer Connection State has changed: failed Peer Connection has gone to failed exiting: Done forwarding ---- SECOND TRY ---- [2023-12-24T12:23:12Z INFO xwebrtc::session] 1:whip,2:live,3:test [2023-12-24T12:23:12Z INFO streamhub] event data: {"Publish":{"identifier":{"WebRTC":{"app_name":"live","stream_name":"test"}},"info":{"id":"1703420592","sub_type":"PushWebRTC","notify_info":{"request_url":"","remote_addr":""}}}} [2023-12-24T12:23:12Z ERROR streamhub] event_loop Publish err: exists [2023-12-24T12:23:12Z INFO webrtc::peer_connection] signaling state changed to have-remote-offer [2023-12-24T12:23:12Z INFO webrtc_ice::mdns] mDNS is using 224.0.0.251:5353 as dest_addr [2023-12-24T12:23:12Z INFO webrtc_mdns::conn] Looping and listening Ok(224.0.0.251:5353) [2023-12-24T12:23:12Z INFO webrtc::peer_connection] signaling state changed to stable [2023-12-24T12:23:12Z DEBUG webrtc_ice::agent::agent_internal] Started agent: isControlling? false, remoteUfrag: 4UQV, remotePwd: 3FWJxdcdXnu/pXS0kQgbdp [2023-12-24T12:23:12Z INFO webrtc_ice::agent::agent_internal] [controlled]: Setting new connection state: Checking [2023-12-24T12:23:12Z WARN webrtc_ice::agent::agent_internal] [controlled]: pingAllCandidates called with no candidate pairs. Connection is not possible yet. [2023-12-24T12:23:12Z WARN webrtc_ice::agent::agent_internal] [controlled]: pingAllCandidates called with no candidate pairs. Connection is not possible yet. [2023-12-24T12:23:12Z INFO webrtc::peer_connection] ICE connection state changed: checking [2023-12-24T12:23:12Z INFO xwebrtc::whip] Connection State has changed checking [2023-12-24T12:23:12Z WARN webrtc_ice::agent::agent_gather] [controlled]: could not listen udp fe:80::: io error: Cannot assign requested address (os error 99) [2023-12-24T12:23:12Z WARN webrtc_ice::agent::agent_gather] [controlled]: could not get server reflexive address udp6 stun:stun.l.google.com:19302: io error: Network is unreachable (os error 101) [2023-12-24T12:23:42Z WARN webrtc_ice::agent::agent_internal] [controlled]: Failed to close candidate udp4 host 172.21.128.1:57332: the agent is closed [2023-12-24T12:23:42Z WARN webrtc_ice::agent::agent_internal] [controlled]: Failed to close candidate udp4 host 172.22.160.1:57332: the agent is closed [2023-12-24T12:23:42Z WARN webrtc_ice::agent::agent_internal] [controlled]: Failed to close candidate udp4 host 192.168.124.30:57332: the agent is closed [2023-12-24T12:23:42Z WARN webrtc_ice::agent::agent_internal] [controlled]: Failed to close candidate udp4 host 172.31.16.1:57332: the agent is closed [2023-12-24T12:23:42Z WARN webrtc_ice::agent::agent_internal] [controlled]: Failed to close candidate udp4 host 172.22.192.1:57332: the agent is closed [2023-12-24T12:23:42Z INFO webrtc_ice::agent::agent_internal] [controlled]: Setting new connection state: Failed [2023-12-24T12:23:42Z INFO webrtc::peer_connection] ICE connection state changed: failed [2023-12-24T12:23:42Z INFO xwebrtc::whip] Connection State has changed failed [2023-12-24T12:23:42Z INFO webrtc::peer_connection] peer connection state changed: failed [2023-12-24T12:23:42Z INFO xwebrtc::whip] Peer Connection State has changed: failed Peer Connection has gone to failed exiting: Done forwarding
OBS logs (only the relevant part):
15:21:50.666: --------------------------------- 15:21:50.666: [x264 encoder: 'simple_video_stream'] preset: veryfast 15:21:50.667: [x264 encoder: 'simple_video_stream'] settings: 15:21:50.667: rate_control: CBR 15:21:50.667: bitrate: 2500 15:21:50.667: buffer size: 2500 15:21:50.667: crf: 23 15:21:50.667: fps_num: 30 15:21:50.667: fps_den: 1 15:21:50.667: width: 1092 15:21:50.667: height: 614 15:21:50.667: keyint: 250 15:21:50.667: 15:21:50.678: --------------------------------- 15:21:50.678: [FFmpeg libopus encoder: 'simple_opus'] bitrate: 160, channels: 2, channel_layout: stereo 15:21:50.678: 15:21:50.701: [obs-webrtc] [whip_output: 'simple_stream'] PeerConnection state is now: Connecting 15:21:52.941: [obs-webrtc] [whip_output: 'simple_stream'] Connect failed: CURL returned result not CURLE_OK 15:21:52.942: [obs-webrtc] [whip_output: 'simple_stream'] PeerConnection state is now: Closed 15:21:52.942: ==== Streaming Stop ================================================ 15:22:06.361: Settings changed (stream 1) 15:22:06.361: ------------------------------------------------ 15:22:07.463: [obs-webrtc] [whip_output: 'simple_stream'] PeerConnection state is now: Connecting 15:22:15.467: [obs-webrtc] [whip_output: 'simple_stream'] Connect failed: CURL returned result not CURLE_OK 15:22:15.467: [obs-webrtc] [whip_output: 'simple_stream'] PeerConnection state is now: Closed 15:22:15.467: ==== Streaming Stop ================================================ 15:23:11.425: [obs-webrtc] [whip_output: 'simple_stream'] PeerConnection state is now: Connecting 15:23:19.427: [obs-webrtc] [whip_output: 'simple_stream'] Connect failed: CURL returned result not CURLE_OK 15:23:19.427: [obs-webrtc] [whip_output: 'simple_stream'] PeerConnection state is now: Closed 15:23:19.427: ==== Streaming Stop ================================================
Again, it seems that the stream cannot be started when WHIP used. Then, I'm trying to start a stream using RTMP to test WHEP.
xiu logs: _~There seems to be a minor problem with RTMP (When we do rtmp://ip:port/appname/streamname, stream_name appears empty and all parameters are set to app_name.),~ I noticed that streamname is taken from stream key. but WHEP is definitely not working at all. Additionally, I tried to connect to STUN servers separately and there were no problems.
@ikircik This project does not currently support the conversion from RTMP to WHEP because audio needs to be decoded and encoded (like AAC to Opus), making it less easy to implement in pure rust.
@EnergoStalin Have you tried OBS? I tried using vdo and found that it requires HTTPS. I'm wondering how you managed to successfully stream through WHIP.
I omit s
directly from url and it connected despite it forcibly adding https from ui flow as i can see by xiu logs and no error from vdo and whep inspection page.
VDO ninja simply say's whip out failed. Used url.
Share url what i initially referred also don't have https(manually removed) so i don't think it's required but i didn't read docs related to that so cant say for sure.
No i didn't tried obs cause there's no such option in my version of obs which is 30.0.2-1 from arch extra distribution it's indeed strange but i don't have browser capture either in this build.
I think i found a different solution for what i'm trying to solve. It's more complex but since xiu cant convert whip to rtmp for now because of reincoding anyway. I should stick to obs websocket api in automating my task stopping trying to use whip in favor of browser source to stream it to youtube via rtmp.
Latest code have already solved this issue so I closed this post.
It seems that whip2rtmp can be implemented using the following two RUST crates :
fdk-aac = "0.5.0"
opus = "0.3.0"
The conversion from whip to RTMP/HTTP-FLV/HLS is basically finished,I have conducted some testing using OBS , anyone who interests with the feature can help test and give me some feedback when founding problems , thanks.
git checkout origin/webrtc2rtmp -b webrtc2rtmp
cargo build && cd target/debug
./xiu -r 1935 -w 8900 -f 8081
XIU version 0.9.1
Describe the bug I followed README.md setting up a WebRTC server. However it failed to stream. Here is log info
To Reproduce My platform is Apple M1 MacbookPro, with macOS 14.2 installed. I am able to stream RTMP so I guess it has nothing to do with my hardware.
Expected behavior A clear and concise description of what you expected to happen.