I have a built game that I’m trying to stream using a TURN server, but all my attempts to get it to work are failing.
So I have the game running on my high-end system in the office and I’m running the WebRTCProxy and the SignalingWebServer on that same machine and I have port forwarding in the office router for 80, 8124, 8888, 90, and 9999. I have a rented Windows Server on Azure where I am running the STUN and TURN servers (The STUN and TURN servers are using the windows binaries from the built UE game) and on that server I have ports 19302 and 19303 open. The STUN part is working great, I can access the web page from the internet and I can see my game and control it just fine. The problem is that the video stream appears to be going direct from the game machine to my browser instead of going through the TURN server. I can stop the TURN server and there is no interruption to the stream, and I don’t the see enough activity on the Azure server NIC to be a video stream. We don’t have a great deal of upload bandwidth at the office, so if we have more than just one user then the quality of the stream starts degrading quickly. Unless I misunderstand how a TURN server works, I should be seeing the stream go from my office to the TURN server on my Azure box, then out to the web clients.
Here is my configuration files:
Start_AWS_WebRTCProxy.bat
@echo off
pushd %~dp0
Powershell.exe -executionpolicy unrestricted -File Start_AWS_WebRTCProxy.ps1
popd
Start_AWS_WebRTCProxy.ps1
$ProcessExe = "WebRTCProxy.exe"
# No default arguments require right now
$Arguments = @()
# Add arguments passed to script to Arguments for executable
$Arguments += $args
Write-Output "Running: $ProcessExe $Arguments"
# Start-Process does not handle an empty -ArgumentList, so if it's empty don't pass that parameter
if($Arguments.count -gt 0){
Start-Process -FilePath $ProcessExe -ArgumentList $Arguments
} else {
Start-Process -FilePath $ProcessExe
}
runAWS_WithTURN.bat
:: Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
@eCHo off
pushd %~dp0
call setup.bat
title Cirrus
::Run node server
::If running with matchmaker web server and accessing outside of localhost pass in --publicIp=<ip_of_machine>
Powershell.exe -executionpolicy unrestricted -File Start_AWS_SignallingServer.ps1
popd
pause
Start_AWS_WithTURN_SignallingServer.ps1
# Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
$PublicIp = Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
$STUNTURN = "104.42.39.38"
Write-Output "Public IP: $PublicIp"
$peerConnectionOptions = "{ \""iceServers\"": {\""urls\"": \""stun:" + $STUNTURN + ":19302\"",\""turn:" + $STUNTURN + ":19303\""], \""username\"": \""uname\"", \""credential\"": \""pass\""}] }"
$ProcessExe = "node.exe"
$Arguments = @("cirrus", "--peerConnectionOptions=""$peerConnectionOptions""", "--publicIp=$PublicIp")
# Add arguments passed to script to Arguments for executable
$Arguments += $args
Write-Output "Running: $ProcessExe $Arguments"
Start-Process -FilePath $ProcessExe -ArgumentList $Arguments -Wait -NoNewWindow
And then on the Azure Server, I have the STUN and TURN servers
Start_STUNServer.bat
:: Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
@eCHo off
pushd %~dp0
title STUN
stunserver.exe 0.0.0.0:19302
popd
Start_AWS_TURNServer.bat
:: Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
@eCHo off
pushd %~dp0
title TURN
Powershell.exe -executionpolicy unrestricted -File Start_AWS_TURNServer.ps1
popd
pause
Start_AWS_TURNServer.ps1
function AddUser{
param(
$realm,
$user,
$pass,
$auth_file,
[switch]$append)
$md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$utf8 = new-object -TypeName System.Text.UTF8Encoding
$hash = [System.BitConverter]::ToString($md5.ComputeHash($utf8.GetBytes("$user" + ":$realm" + ":$pass")))
$hash = $hash.ToLower() -replace '-', ''
if($append){
"$user=$hash" | Out-File -FilePath $auth_file -Append -Encoding ascii
} else {
"$user=$hash" | Out-File -FilePath $auth_file -Encoding ascii
}
}
$RemoteIp = Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
$LocalIp = (Test-Connection -ComputerName $env:ComputerName -Count 1).IPV4Address.IPAddressToString
Write-Output "External IP: $RemoteIp"
Write-Output "Private IP: $LocalIp"
$AuthFile = "turnserver_auth.txt"
$Realm = "PixelServer"
$ProcessExe = ". urnserver.exe"
$Arguments = "0.0.0.0:19303 $RemoteIp $Realm $AuthFile"
Write-Output "Arguments: $Arguments"
$TurnUsername = "uname"
$TurnPassword = "pass"
AddUser $Realm $TurnUsername $TurnPassword $AuthFile
Write-Output "Running: $ProcessExe $Arguments"
Start-Process -FilePath $ProcessExe -ArgumentList $Arguments -Wait -NoNewWindow
What am I missing? I’ve been pulling my hair out on this one.
Thanks,
Ray