编程知识 cdmana.com

Intranet coturn (turn server) connectivity test and verification | update challenge in August

Use Trickle ICE verification TURN Server Whether it can work normally ,Trickle ICE and coturn Of log There are errors in printing , Dare not confirm whether the configuration is correct , After a complete test environment is built and verified, you can finally rest assured by capturing packages , Relieved my doubts .

Installation and configuration

Introduction Online TURN Server There are many articles on installation and configuration , I was in CentOS Upper use , The reference is Centos7 install coturn Deploy a set of STUN/TURN service webRTC Hole server .

Follow the steps of the article step by step, basically OK 了 , You need to pay attention to a problem ,4.5.2 Version in use CentOS 7 The system does not work properly , The fallback version is OK , At that time, I thought I had checked the configuration file for a long time , Finally, I see the following two Issue not have understood until then .

Use Trickle ICE test

Refer to the articles on the Internet to use Trickle ICE test TURN Server , Said to see the following Done That's all right. .

But see the following error message , There is still a lot of doubt 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.

image.png

By looking at Trickle ICE The source code discovery specifies iceTransportPolicy It can make ICE Use it directly TURN Server Forward instead of using the default priority , In this way, packet capture observation and verification can be carried out TURN Server Whether it is forwarded normally .

image.png

As you can see from the diagram ,ICE Got three UDP Host candidates and three TCP Host candidates for , And a relay candidate , Because it's in the same LAN , Cannot get 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

Type Medium host Is a host candidate ,relay Is a relay candidate

Build environment verification

1. The network environment

  • Network segment 1 :192.168.0.xxx
  • Network segment II :192.168.100.xxx

Network segment 1 is the main network , Simulate the public network environment ,TURN Server and Janus Your server is on this network , Both services are on one device ,IP The address is 192.168.0.221.

Network segment 2 is self network , Analog LAN , Interactive computers in this network , Subnet segment router WAN IP yes 192.168.0.251.

2. Use Trickle ICE test STUN and TURN

Before comparison , Added server reflection candidates , explain STUN Normal work

image.png

3. Use Janus Test capture

modify RTCPeerConnection Initialize configuration , take iceTransportPolicy Set to relay, Then start interacting and using WireShark Carry out the bag .

    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 code 

After the interaction publish The flow succeeded , Observe Janus news , The browser reported candidate There's only relay Address , It's almost certain TURN Server It works .

image.png

adopt wireshark You can see , All sent to 192.168.0.221 Of udp Packet destination ports are 3478, It can be determined that the flow is through TURN Server Forwarding to Janus Of .

image.png

image.png

Profile reference

Configuration during testing , If necessary, please refer to

# 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-mech
 Copy code 

Reference material :

版权声明
本文为[xiaosongxiaosong]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/08/20210802181618389i.html

Scroll to Top