trtc.on(TRTC.EVENT.ERROR, error => {// User network firewall restrictions may cause audio and video calls to fail.// At this time, guide users to change networks or check network firewall settings.if (error.code === TRTC.ERROR_CODE.OPERATION_FAILED && error.extraCode === 5501) {}});
WebRTC (H5) | Ports |
TCP | 443 |
UDP | 8000, 8080, 8800, 843, 443, 16285 |
apisgp.my-imcloud.com# version after v5.5.0*.rtc-web.com*.rtc-web.io# version before v5.5.0signailing.rtc.tencentcloud.comschedule.rtc.tencentcloud.com*.rtc.tencentcloud.com
Solution | Applicable scenarios | Network requirements |
A | Users can access a specific external proxy server on the network | The proxy server is deployed on the external network, and the internal network firewall needs to open a whitelist to allow internal network users to access the external proxy server. |
B | Users can only access an internal proxy server on the network | The proxy server is deployed on the internal network, and the internal network firewall needs to open a whitelist to allow the internal proxy server to access the external network. |
vi /etc/nginx/nginx.conf
http {server {# The access domain name of the Nginx serverserver_name proxy.example.com;# The access port of the Nginx serverlisten 443;ssl on;location /ws/ { # Corresponding to the websocketProxy parameter in setProxyServerproxy_pass https://signaling.rtc.qq.com/; # TRTC serverproxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}location /logger/ { # Corresponding to the loggerProxy parameter in setProxyServerproxy_pass https://yun.tim.qq.com/;}# SSL certificate corresponding to the domain name, used for HTTPS, users need to apply for it themselvesssl_certificate ./crt/1_proxy.trtcapi.com_bundle.crt;ssl_certificate_key ./crt/2_proxy.trtcapi.com.key;}}
sudo nginx -s reload
#!/usr/bin/env bash# current file name is turn.sh# ref:# https://gabrieltanner.org/blog/turn-server STEP 3 testing turn server# https://medium.com/av-transcode/what-is-webrtc-and-how-to-setup-stun-turn-server-for-webrtc-communication-63314728b9d0# as super-user# usage: current_program <external-ip>set -xset -eip apwdwhoamidisplay_usage() {echo "This script must be run with super-user privileges."echo -e "\\nUsage: $0 <external-ip> \\ne.g. $0 154.8.246.205"}# if less than two arguments supplied, display usageif [ $# -lt 1 ]thendisplay_usageexit 1fiif [[ $1 =~ ^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$ ]]; thenecho "get external ip $1"elseecho "wrong external ip $1 , must not have whitespace, tab and other char"exit 2fiyum install -y coturn# $1 is <external-ip>cat <<EOF > /etc/coturn/turnserver.confexternal-ip=$1listening-port=3478lt-cred-mechmax-port=65535min-port=20000no-dtlsno-tlsrealm=tencentuser=turn:turnverboseEOF
chmod +x turn.sh
#sudo ./turn.sh <server public IP>
sudo ./turn.sh 14.3.3.3
systemctl start coturn# Check if turn is started successfullyps aux | grep coturn# If you want to restart the service, executeservice coturn restart
# The start script in Solution 2-A is the server's external address, e.g. 14.3.3.3sudo . /turn.sh 14.3.3.3# In Solution 2-B, the start script fills in the server's intranet address,# e.g. 10.0.0.4 for the intranetsudo . /turn.sh 10.0.0.4
const trtc = TRTC.create();await trtc.enterRoom({...,proxy: {// Set up a Websocket proxy to relay signaling data packets between the SDK and the TRTC backend.websocketProxy: 'wss://proxy.example.com/ws/',// Set up a turn server to relay media data packets between the SDK and the TRTC backend. 14.3.3.3:3478 is the IP address and port of the turn server.turnServer: { url: '14.3.3.3:3478', username: 'turn', credential: 'turn', credentialType: 'password' },// By default, the SDK will connect to trtc server directly, if connection failed, then SDK will try to connect the TURN server to relay the media data. You can set 'relay' to force the connection through the TURN server.iceTransportPolicy: 'all',// By default, the SDK reports logs to the yun.tim.qq.com domain name. If this domain name cannot be accessed in your internal network, you need to whitelist the domain name or configure the following log proxy.// Set up a log reporting proxy. Logs are key data for troubleshooting, so be sure to set up this proxy.loggerProxy: 'https://proxy.example.com/logger/',}})
Was this page helpful?