EpicGames / PixelStreamingInfrastructure

Moved to: https://github.com/EpicGamesExt/PixelStreamingInfrastructure
https://github.com/EpicGamesExt/PixelStreamingInfrastructure
MIT License
552 stars 260 forks source link

Pixel Streaming works on a local setup but fails to connect when using TURN in a NAT enabled network. #173

Closed VegetableWithChicken closed 1 year ago

VegetableWithChicken commented 1 year ago

Component your feature request relates to

Problem your feature solves? Please describe. the turn server can run by HTTP in NAT,

Describe the solution you'd like

  1. unreal --pixelstremingip="publicip",and run
  2. config "PublicIp":"XXX.XXX.XXX.XXX"
  3. run Start_WithTURN_SignallingServer.ps1 by powershell
  4. and open the web ,it black

Additional context

lukehb commented 1 year ago

For extra context here, do you mean running the TURN server on say port 80?

VegetableWithChicken commented 1 year ago

For extra context here, do you mean running the TURN server on say port 80?

I use localhost to start local pixelstreaming is OK, but after turning on Turn and network penetration, open the display black screen on the public network, the internal network opening screen shows normal, I have set publicIP as public IP. QA:

  1. how to deploy ?
  2. how to setting the turn server
  3. Whether you need to config HTTPS=true ?
lukehb commented 1 year ago

Are you running the TURN server outside the NAT?

Ideal setup is:

$peerConnectionOptions = "{ \""iceServers\"": [{\""urls\"": [\""stun:" + stun.l.google.com:19302 + "\"",\""turn:" + $global:TurnServer + "\""], \""username\"": \""PixelStreamingUser\"", \""credential\"": \""AnotherTURNintheroad\""}] }"

Where global:TurnServer is the public IP:port of the TURN server.

For 3) - do you need HTTPS=true? No, only if you want the website to be served with https, but for testing TURN setup, no it is not required.

Many users choose to run the TURN server on port 80 or 443 as they are often left open on corporate networks and give the greatest chance of a successful connection.

VegetableWithChicken commented 1 year ago

"stun:" + stun.l.google.com:19302 +

it should change my publicip +port ??

lukehb commented 1 year ago

The STUN part is simply to use Google's existing STUN server, I provided this one: "stun:" + stun.l.google.com:19302 as it is one I know works. However, you can also point this at your own STUN server if you so wish.

VegetableWithChicken commented 1 year ago

The STUN part is simply to use Google's existing STUN server, I provided this one: "stun:" + stun.l.google.com:19302 as it is one I know works. However, you can also point this at your own STUN server if you so wish.

i have connected inside turn ,but how to set param of unreal.exe

VegetableWithChicken commented 1 year ago

The STUN part is simply to use Google's existing STUN server, I provided this one: "stun:" + stun.l.google.com:19302 as it is one I know works. However, you can also point this at your own STUN server if you so wish.

streamer LEGACY disconnected: 4000 - Cannot find type field in SS message: {"peerConnectionOptions":{"iceServers":[{"urls":["stun:","turn:XX.XX.XX.XX:80" 13:58:36.602 unsubscribing all players on LEGACY 13:58:36.647 Streamer connected: ::ffff:XX.XX.XX.XX:80 13:58:36.647 unknown <- {"type":"identify"} streamer LEGACY disconnected: 4000 - Cannot find type field in SS message: {"peerConnectionOptions":{"iceServers":[{"urls":["stun:","turn:XX.XX.XX.XX:80 13:58:36.771 unsubscribing all players on LEGACY 13:58:36.816 Streamer connected: ::ffff:XX.XX.XX.XX:80 13:58:36.816 unknown <- {"type":"identify"} streamer LEGACY disconnected: 4000 - Cannot find type field in SS message: {"peerConnectionOptions":{"iceServers":[{"urls":["stun:","turn:XX.XX.XX.XX:80 13:58:36.941 unsubscribing all players on LEGACY 13:58:36.977 Streamer connected: ::ffff:XX.XX.XX.XX:80 13:58:36.977 unknown <- {"type":"identify"} streamer LEGACY disconnected: 4000 - Cannot find type field in SS message: {"peerConnectionOptions":{"iceServers":[{"urls":["stun:","turn:XX.XX.XX.XX:80 13:58:37.110 unsubscribing all players on LEGACY 13:58:37.155 Streamer connected: ::ffff:XX.XX.XX.XX:80 13:58:37.155 unknown <- {"type":"identify"}

lukehb commented 1 year ago

Can you please share your modified scripts? I think you didn't escape the string properly perhaps.

VegetableWithChicken commented 1 year ago

你能分享你修改后的脚本吗?我认为您可能没有正确转义字符串。 //cirrus.js
let clientConfig = {"peerConnectionOptions":{"iceServers":[{"urls":["stun:140.206.49.220:19302","turn:140.206.49.220:19303"]}]}};

//config.json
{
"UseFrontend": false,
"UseMatchmaker": false,
"UseHTTPS": false, "UseAuthentication": false, "LogToFile": true, "LogVerbose": true, "HomepageFile": "player.html", "AdditionalRoutes": {}, "EnableWebserver": true, "MatchmakerAddress": "", "MatchmakerPort": 9999, "PublicIp": "140.206.49.220", "HttpPort": 81, "HttpsPort": 443, "StreamerPort": 8888, "SFUPort": 8889, "MaxPlayerCount": -1 }

//Start_WithTURN_SignallingServer.ps1

# Copyright Epic Games, Inc. All Rights Reserved.

. "$PSScriptRoot\Start_Common.ps1" $args

set_start_default_values "y" "y" # Set both TURN and STUN server defaults
use_args($args)
print_parameters

Push-Location $PSScriptRoot

Start-Process -FilePath "PowerShell" -ArgumentList ".\Start_TURNServer.ps1" -WorkingDirectory "$PSScriptRoot"

#$peerConnectionOptions = "{ \""iceServers\"": [{\""urls\"": [\""stun:" + $global:StunServer + "\"",\""turn:" + $global:TurnServer + "\""], \""username\"": \""qxsy-openapi\"", \""credential\"": \""chong.peng_qx\""}] }"
$peerConnectionOptions = "{ \""iceServers\"": [{\""urls\"": [\""stun:" + $global:StunServer + "\"",\""turn:" + $global:TurnServer + "\""]}] }"
$ProcessExe = "platform_scripts\cmd\node\node.exe"
$Arguments = @("cirrus", "--peerConnectionOptions=""$peerConnectionOptions""", "--PublicIp=$global:PublicIp")
# Add arguments passed to script to Arguments for executable
$Arguments += $args

Push-Location $PSScriptRoot\..\..\
Write-Output "Running: $ProcessExe $Arguments"
Start-Process -FilePath $ProcessExe -ArgumentList $Arguments -Wait -NoNewWindow
Pop-Location

Pop-Location
VegetableWithChicken commented 1 year ago

when i connected turn server ,and log:

13:56:53.284 unknown <- {"type":"identify"}
13:56:53.380 __LEGACY__ -> {"type":"endpointId","id":""}
VegetableWithChicken commented 1 year ago

still faild

VegetableWithChicken commented 1 year ago
  1. export port to public in NAT,