接着对使用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
参考: