When using Trickle ICE to verify whether The TURN Server works properly, both Trickle ICE and Coturn logs had error prints, and they were afraid to confirm whether the configuration was correct. After setting up a complete test environment to verify, they were finally reassured by capturing packages, which helped them to remove their doubts.
Installation and configuration
Install coturn Server, install STUN/TURN Server, install STUN/TURN Server, install STUN/TURN Server, install STUN/TURN Server, install STUN/TURN Server, install STUN/TURN Server
According to the steps of the article step by step operation is basically OK, encountered a problem need to pay attention to, 4.5.2 version in the use of CentOS 7 system does not work properly, the version can be rolled back, thought that the configuration file problems for a long time, finally see the following two issues only know.
- Github.com/coturn/cotu…
- Github.com/coturn/cotu…
Use the Trickle ICE test
Refer to the article online to test TURN Server using Trickice. Just see Done below.
However, seeing the following error message, I still have great doubts about whether it can work properly.
The server turn: 192.168.0.221:3478? transport=udp returned an error with code=701: TURN allocate request timed out.
A look at the source code for Trickle ICE shows that specifying the iceTransportPolicy allows ICE to use TURN Server directly for forwarding instead of using the default priority. In this way, packets can be captured to verify that the TURN Server forwards normally.
As you can see from the figure, ICE gets three UDP host candidates, three TCP host candidates, and one relay candidate, because it is on the same LAN and cannot get the reflection candidate.
Time | Component | Type | Foundation | Protocol | Address | Port | Priority |
---|---|---|---|---|---|---|---|
0.020 | rtp | host | 3598251130 | udp | 172.31.112.1 | 50126 | 126 | 32542 | 255 |
0.021 | rtp | host | 6840418 | udp | 192.168.0.23 | 50127 | 126 | 32286 | 255 |
0.021 | rtp | host | 1553261686 | udp | 192.168.30.23 | 50128 | 126 | 32030 | 255 |
0.072 | rtp | relay | 4222569549 | udp | 192.168.0.221 | 20412 | 2 | 32286 | 255 |
0.122 | rtp | host | 2566588554 | tcp | 172.31.112.1 | 9 | 90 | 32542 | 255 |
0.122 | rtp | host | 1324063890 | tcp | 192.168.0.23 | 9 | 90 | 32286 | 255 |
0.122 | rtp | host | 303503494 | tcp | 192.168.30.23 | 9 | 90 | 32030 | 255 |
39.867 | Done | ||||||
39.871 |
In Type, host is a host candidate and relay is a trunk candidate
Set up environment verification
1. Network environment
- Network segment 1:192.168.0.xxx
- Network segment 2:192.168.100.xxx
The first network segment is the master network, which simulates the public network environment. The servers of TURN Server and Janus are on this network, and the two services are on the same device with the IP address of 192.168.0.221.
Network segment 2 is the self-network, analog LAN, interactive computers in this network, subnet segment router WAN IP is 192.168.0.251.
2. Test STUN and TURN with Trickle ICE
Before comparison, there are more server reflection candidates, indicating that STUN works normally
3. Use Janus to test packet capture
Modify the initial configuration of RTCPeerConnection, set iceTransportPolicy to Relay, and then start the interaction and use WireShark to capture packets.
const pc = new RTCPeerConnection({
iceServers: [{urls: ['turn: 192.168.0.221:3478'].username: 'test'.credential: '123456'.credentialType: 'password'],},iceTransportPolicy: 'relay'.bundlePolicy: 'max-bundle'.rtcpMuxPolicy: 'require'.// certificates: '',
iceCandidatePoolSize: '0'.sdpSemantics: 'unified-plan'.tcpCandidatePolicy: 'disable'.IceTransportsType: 'nohost'});Copy the code
After the publish flow is successful, observe the Janus message, the browser reported candidate only in the relay address, basically can confirm that the TURN Server is working properly.
According to the filtering of Wireshark, the destination port of all UDP packets sent to 192.168.0.221 is 3478. Therefore, it can be determined that the traffic is forwarded to Janus through the TURN Server.
Configuration File Reference
For the configuration during the test, please refer to the following if necessary
# TURN server name and realm realm=192.168.0.221 server-name= turnServer # Use fingerprint in TURN message fingerprint # IPs the TURN server listens to # listening-ip=192.168.0.221 # External ip-address of the TURN server #external-ip=121.199.22.135 # Main Listening port Listening-port =3478 # Further ports that are open for communication min-port=20000 max-port=22000 # Enable verbose logging verbose # Specify the user for the TURN authentification user=test:123456 # Enable long-term credential mechanism lt-cred-mechCopy the code
References:
- Blog.csdn.net/haeasringna…
- Joey. Blue / 2018/12/10 /…