paullouisageneau / libjuice

JUICE is a UDP Interactive Connectivity Establishment library
Mozilla Public License 2.0
432 stars 82 forks source link

the issue with the TURN forwarding. #279

Open xicilion opened 6 days ago

xicilion commented 6 days ago

I am using WebRTC and a browser to establish a data channel, but some issues occur when a TURN server is needed. Here are the specific symptoms:

using coturn

When using coturn as TURN server, juice can't get candidates. The specific log information is as follows:

2024-11-16 02:09:21.200 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1227: Missing integrity in STUN message
2024-11-16 02:09:21.201 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1301: Ignoring invalid TURN Allocate message
2024-11-16 02:09:22.201 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1227: Missing integrity in STUN message
2024-11-16 02:09:22.201 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1301: Ignoring invalid TURN Allocate message
2024-11-16 02:09:24.202 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1227: Missing integrity in STUN message
2024-11-16 02:09:24.202 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1301: Ignoring invalid TURN Allocate message
2024-11-16 02:09:28.204 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1227: Missing integrity in STUN message
2024-11-16 02:09:28.204 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1301: Ignoring invalid TURN Allocate message
2024-11-16 02:09:35.854 INFO  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1430: STUN server binding successful
2024-11-16 02:09:35.854 INFO  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1449: Got STUN mapped address 240e:3a3:60b:d041:b577:4372:6fc9:8d1d:62434 from server
2024-11-16 02:09:36.125 INFO  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1430: STUN server binding successful
2024-11-16 02:09:36.126 INFO  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1449: Got STUN mapped address 49.65.154.14:64072 from server
2024-11-16 02:09:36.206 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1227: Missing integrity in STUN message
2024-11-16 02:09:36.206 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1301: Ignoring invalid TURN Allocate message
2024-11-16 02:09:44.193 INFO  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:886: TURN allocation failed

Other implementations of WebRTC, such as Chrome and React Native WebRTC, work well with coturn.

using violet

When using violet as the TURN Server, juice can work properly and establish connections.

But other WebRTC implementations, such as Chrome and React Native WebRTC, can obtain candidates, but cannot establish normal communication. Because there are no specific logs available, the detailed error information is still unclear.

paullouisageneau commented 5 days ago

When using coturn as TURN server, juice can't get candidates. The specific log information is as follows:

2024-11-16 02:09:21.200 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1227: Missing integrity in STUN message
2024-11-16 02:09:21.201 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1301: Ignoring invalid TURN Allocate message
2024-11-16 02:09:22.201 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1227: Missing integrity in STUN message
2024-11-16 02:09:22.201 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1301: Ignoring invalid TURN Allocate message
2024-11-16 02:09:24.202 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1227: Missing integrity in STUN message
2024-11-16 02:09:24.202 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1301: Ignoring invalid TURN Allocate message
2024-11-16 02:09:28.204 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1227: Missing integrity in STUN message
2024-11-16 02:09:28.204 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1301: Ignoring invalid TURN Allocate message
2024-11-16 02:09:35.854 INFO  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1430: STUN server binding successful
2024-11-16 02:09:35.854 INFO  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1449: Got STUN mapped address 240e:3a3:60b:d041:b577:4372:6fc9:8d1d:62434 from server
2024-11-16 02:09:36.125 INFO  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1430: STUN server binding successful
2024-11-16 02:09:36.126 INFO  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1449: Got STUN mapped address 49.65.154.14:64072 from server
2024-11-16 02:09:36.206 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1227: Missing integrity in STUN message
2024-11-16 02:09:36.206 WARN  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:1301: Ignoring invalid TURN Allocate message
2024-11-16 02:09:44.193 INFO  [15355595] [rtc::impl::IceTransport::LogCallback@395] juice: agent.c:886: TURN allocation failed

It would mean the TURN server does not ask for authentication as expected (by specification message integrity is mandatory in allocate response). Are you sure the TURN server is set up properly with authentication enabled? The verbose log would help knowing what is happening exactly.

Other implementations of WebRTC, such as Chrome and React Native WebRTC, work well with coturn.

Does it work with the same server and the same credentials? Just a note, Chrome and React Native WebRTC are basically the same implementation as both run libwebrtc.

When using violet as the TURN Server, juice can work properly and establish connections.

But other WebRTC implementations, such as Chrome and React Native WebRTC, can obtain candidates, but cannot establish normal communication. Because there are no specific logs available, the detailed error information is still unclear.

How do you run violet? The verbose log of violet would help.

xicilion commented 5 days ago

It would mean the TURN server does not ask for authentication as expected (by specification message integrity is mandatory in allocate response). Are you sure the TURN server is set up properly with authentication enabled? The verbose log would help knowing what is happening exactly.

It is true that I can get candidates by modifying any authentication information in the browser. I modified the configuration of coturn, and now juice can work properly. I'm also thinking if Juice can be compatible with this situation.

How do you run violet? The verbose log of violet would help.

I asked my colleagues about it, the log of violet server is normal for now. We are still working on identifying the specific reason for the connection failure.