接着對使用coTurn搭建的STUN/TURN服務使用turnutils_uclient程序測試其TURN服務是否正常。
直接連接服務測試服務是否正常。為保證測試使用的服務是TURN服務,在TURN服務啟動時,關掉STUN服務。
在TURN服務啟動時,如果是命令行,加入"--no-stun"配置;如果使用配置文件的話,加入"no-stun"選項。
使用coTurn服務啟動TURN服務后,執行以下命令即可:
turnutils_uclient -v -t -T -u test1 -w 1234 61.18.11.123
其中
-v 表示給出詳細提示
-t 使用TCP協議(默認使用UDP)
-T TCP協議中繼傳輸(默認是UDP)
-u TURN的用戶名
-w TURN服務對應用戶的密碼
61.18.11.123 TURN服務的IP地址
執行結果如下:

1 0: IPv4. Connected from: 192.168.2.222:9481 2 0: IPv4. Connected to: 61.18.11.123:3478 3 0: allocate sent 4 0: allocate response received: 5 0: allocate sent 6 0: allocate response received: 7 0: success 8 0: IPv4. Received relay addr: 61.18.11.123:65502 9 0: clnet_allocate: rtv=0 10 0: refresh sent 11 0: refresh response received: 12 0: success 13 0: IPv4. Connected from: 192.168.2.222:9482 14 0: IPv4. Connected to: 61.18.11.123:3478 15 0: IPv4. Connected from: 192.168.2.222:9483 16 0: IPv4. Connected to: 61.18.11.123:3478 17 0: allocate sent 18 0: allocate response received: 19 0: allocate sent 20 0: allocate response received: 21 0: success 22 0: IPv4. Received relay addr: 61.18.11.123:65522 23 0: clnet_allocate: rtv=0 24 0: refresh sent 25 0: refresh response received: 26 0: success 27 0: allocate sent 28 0: allocate response received: 29 0: allocate sent 30 0: allocate response received: 31 0: success 32 0: IPv4. Received relay addr: 61.18.11.123:65510 33 0: clnet_allocate: rtv=0 34 0: refresh sent 35 0: refresh response received: 36 0: success 37 0: create perm sent: 61.18.11.123:65510 38 0: cp response received: 39 0: success 40 0: create perm sent: 61.18.11.123:65522 41 0: cp response received: 42 0: success 43 0: tcp connect sent 44 0: connection bind sent 45 0: connect bind response received: 46 0: success 47 0: IPv4. TCP data network connected to: 61.18.11.123:3478 48 0: connection bind sent 49 0: connect bind response received: 50 0: success 51 0: IPv4. TCP data network connected to: 61.18.11.123:3478 52 0: Total connect time is 0 53 0: 2 connections are completed 54 1: start_mclient: msz=2, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0 55 2: start_mclient: msz=2, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0 56 3: start_mclient: msz=2, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0 57 4: start_mclient: msz=2, tot_send_msgs=5, tot_recv_msgs=5, tot_send_bytes ~ 500, tot_recv_bytes ~ 500 58 4: done, connection 0x600051970 closed. 59 4: done, connection 0x600072160 closed. 60 4: start_mclient: tot_send_msgs=10, tot_recv_msgs=10 61 4: start_mclient: tot_send_bytes ~ 1000, tot_recv_bytes ~ 1000 62 4: Total transmit time is 4 63 4: Total lost packets 0 (0.000000%), total send dropped 0 (0.000000%) 64 4: Average round trip delay 128.400000 ms; min = 10 ms, max = 189 ms 65 4: Average jitter 47.600000 ms; min = 20 ms, max = 179 ms
參考: