Problem while connecting PS4 game client to a windows dedicated server. Error: binding to port 0 failed

Hello,
I’m trying to connect a PS4 game client to a windows dedicated server but I’m getting the following error:

LogNet:Warning: Failed to init net driver ConnectURL: [dedicated ip]//Game/Maps/StartupMap: BSD: binding to port 0 failed (5)
LogNet:Warning: error initializing the network stack
LogNet: DestroyNamedNetDriver PS4NetDriver_0 [PendingNetDriver]
LogExit: PendingNetDriver PS4NetDriver_0 shut down
LogNet:Warning: Travel Failure: [PendingNetGameCreateFailure]: BSD: binding to port 0 failed (5)
LogNet: TravelFailure: PendingNetGameCreateFailure, Reason for Failure: 'BSD: binding to port 0 failed (5)'
LogNet:Warning: Travel Failure: [ClientTravelFailure]:
LogNet: TravelFailure: ClientTravelFailure, Reason for Failure: ''

I have made the following change on PS4SocketSubsystem.cpp to set bInIsP2P to false:

//return ( Socket != INVALID_SOCKET ) ? new FPS4Socket( Socket, SOCKTYPE_Datagram, SocketDescription, true, this ) : nullptr;
return (Socket != INVALID_SOCKET) ? new FPS4Socket(Socket, SOCKTYPE_Datagram, SocketDescription, false, this) : nullptr;

And I have a custom PS4Engine.ini file with this content:

[/Script/Engine.Engine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemPS4.PS4NetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
DefaultPlatformService=PS4
PollingIntervalInMs=20

[OnlineSubsystemPS4]
bEnabled=true

And also tried with this:

[/Script/Engine.Engine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemPS4.PS4NetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
DefaultPlatformService=PS4
PollingIntervalInMs=20

[OnlineSubsystemPS4]
bEnabled=true

But both of them finally gives me the same error when trying to connect to the server.

I have no problems with a windows game client so I think is a PS4 related problem.
Does anyone know how to make it run?

Thanks.

Ok, I solved it.

I leave my Game\Config\PS4\PS4Engine.ini file like this:

Game\Config\PS4\PS4Engine.ini
[/Script/Engine.Engine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemPS4.PS4NetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
DefaultPlatformService=PS4
PollingIntervalInMs=20

[OnlineSubsystemPS4]
bEnabled=true

And leave PS4SocketSubsystem.cpp without changes.
But I have changed a code line on PS4NetDriver.cpp:

//return SocketSubsystem->CreateSocket( FName( "UDPP2P" ), TEXT( "Unreal" ) );
return SocketSubsystem->CreateSocket( NAME_DGram, TEXT("Unreal"));

This way I force PS4 to don’t use P2P in order to connect to a Windows dedicated server normally.

And a better solution, in which you haven’t to change any code on the engine: just tell the game to use the default IpNetDriver instead the PS4 one. You can do that because the only method that PS4NetDriver implements is the one that use CreateSocket.

So just set the Game\Config\PS4\PS4Engine.ini file like this:

[/Script/Engine.Engine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
DefaultPlatformService=PS4
PollingIntervalInMs=20

[OnlineSubsystemPS4]
bEnabled=true

Oh thanks for this! I had the same issue but I was trying to connect to a PS4 as a listen server, I don’t know much about networking and I still need to understand what an UDPP2P socket does, but this solved my issue! thanks a ton.