question

vcoimbra avatar image
vcoimbra asked

[UE4 OSS] Proper way of executing client travel on P2P match (from matchmaking)

I've implemented a basic 1v1 matchmaking for my game in Unreal Engine 4 using the Online Subsystem Plugin for PlayFab (https://github.com/PlayFab/PlayFabMultiplayerUnreal). Matching seems to work correctly, as a session is successfully created for both players.

The issue I'm having is that attempting to make the machine designated as the client travel to the host doesn't work. The client times out after some time.

This is the code I'm using as the delegate for when a match is found successfully:

void UStartMatchmakingCallbackProxy::OnMatchmakingComplete(FName SessionName, bool Successful)
{
    auto SessionsInterface = Online::GetSessionInterface(GEngine->GetWorldFromContextObjectChecked(WorldContextObject));
    SessionsInterface->ClearOnMatchmakingCompleteDelegate_Handle(MatchmakingCompleteDelegateHandle);

    if (Successful)
    {
        UE_LOG_ONLINE_SESSION(Log, TEXT("Matchmaking found a match."));

        auto NamedSession = SessionsInterface->GetNamedSession(SessionName);

        if (NamedSession->bHosting)
        {
            UE_LOG_ONLINE_SESSION(Log, TEXT("Matchmaking: we're the host."));
            OnSuccessAsHost.Broadcast();
        }
        else
        {
            OnSuccessAsClient.Broadcast();

            FString ConnectString;
            if (PlayerControllerWeakPtr.IsValid() && SessionsInterface->GetResolvedConnectString(NAME_GameSession, ConnectString))
            {
                UE_LOG_ONLINE_SESSION(Log, TEXT("Matchmaking as client: traveling to %s"), *ConnectString);
                PlayerControllerWeakPtr->ClientTravel(ConnectString, TRAVEL_Absolute);
                return;
            }
        }
    }
    else
    {
        UE_LOG_ONLINE(Log, TEXT("Matchmaking failed."));
        OnFailure.Broadcast();
    }
}

From what I've investigated, the GetResolvedConnectString always seems to return "0.0.0.0:5000" no matter what and that's possibly what's tripping Unreal up, but that's just a guess.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

vcoimbra avatar image vcoimbra commented ·

I can't find the edit button so I'll add this as a comment. These are the logs I got from an attempt:

LogNet: Warning: FOnlineSubsystemPlayFab::OnEndpointCreate: Created Party Endpoint: 2
LogNet: Browse: 0.0.0.0:5000/Game/Levels/MainMenuLevel
LogNet: World NetDriver shutdown PlayFabNetDriver_0 [GameNetDriver]
LogNet: DestroyNamedNetDriver PlayFabNetDriver_0 [GameNetDriver]
LogExit: GameNetDriver PlayFabNetDriver_0 shut down
PacketHandlerLog: Loaded PacketHandler component: Engine.EngineHandlerComponentFactory (StatelessConnectHandlerComponent)
LogNet: Game client on port 5000, rate 10000
LogSockets: Warning: FOnlineSubsystemPlayFab::GetPartyEndpoint: Could not find Enpoint for UniqueId 1
LogNet: UIpConnection::HandleSocketSendResult: Socket->SendTo failed with error 29 (SE_ENOTCONN). [UNetConnection] RemoteAddr: PlayFab.1:1, Name: PlayFabNetConnection_0, Driver: PendingNetDriver PlayFabNetDriver_1, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID Connection beginning close timeout (Timeout = 0).
0 Likes 0 ·
vcoimbra avatar image vcoimbra commented ·

Here's a more complete log of what's happening on the client (Verbose being turned on for LogOnline): https://pastebin.com/xFWBJjBf

Has to pastebin it because it wouldn't fit here otherwise.

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha commented ·

I will dig into it.

0 Likes 0 ·

1 Answer

·
vcoimbra avatar image
vcoimbra answered

Alright, we figured it out, it was a problem on our end. The issue is that I was asking Unreal to listen before I had a session going (i.e., while I was searching). The fix was to only start listening after a match has been found.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.