Hi, we recently upgrade our project from UE5.02 to UE5.1, and it broke our online multiplayer setup- we’re using the EOS online subsystem.
I did some digging to see what changed between the two versions, and for some reason now when a client gets the session using SessionInterface->GetNamedSession(), the RegisteredPlayers array is empty.
This issue only happens for clients, and the session host is able to see the correct RegisteredPlayers array. Below is some example code to get the session and check the number of RegisteredPlayers (and a commented bit showing how we sent peer-to-peer messages successfully before).
I’m not sure if removing the client’s access to RegisteredPlayers was a security fix done deliberately by Epic, or a possible bug. I don’t know a way to handle peer-to-peer messaging if the client can’t access the RegisteredPlayers in the session.
Any help or workarounds would be much appreciated!
//Example code:
void UMultiplayerSessionsSubsystem::SendMessageToAllPlayers()
{
//Use the EOS API to get the named session (we previously stored CurrentSessionName when joining the session)
FNamedOnlineSession* session = SessionInterface->GetNamedSession(CurrentSessionName);
//Make sure we're getting the correct session
//This outputs the same string for the host and client
UE_LOG(LogTemp, Error, TEXT("session->GetSessionIdStr(): %s"), *session->GetSessionIdStr());
//For testing, output the number of registered players. It SHOULD return the number of players in the session, excluding our own player
//For the host, this outputs 1 (correct). For the client, this outputs 0 (incorrect).
UE_LOG(LogTemp, Error, TEXT("session->RegisteredPlayers.Num(): %d"), session->RegisteredPlayers.Num());
//Note: session->OwningUserId and session->LocalOwnerId are also empty for the client
//-----------------------------------------------------
//This is how we use the remote net id to send a message (worked fine in UE5.02)
//There may be some pseudocode in here, because I just added it as FYI
//None of this really matters if we can't get a list of registered players on the client
/*
//Each entry in the registered players array is a FUniqueNetIdPtr- get the first one
FUniqueNetIdPtr remoteNetId = session->RegisteredPlayers[0];
//Parse out the product user id from the net id
//The net id includes both account id and product id, delimited with "|"
FString fullNetId = remoteNetId.Get()->ToString();
TArray<FString> parsedArray;
fullNetId.ParseIntoArray(parsedArray, TEXT("|"));
EOS_ProductUserId productUserId = EOS_ProductUserId_FromString(TCHAR_TO_ANSI(*parsedArray[1]));
//Construct a remote address from the productUserId
FInternetAddrEOS remoteAddressEOS = FInternetAddrEOS(productUserId , CurrentSessionIdString, 0);
//Use SocketEOS to send the message to the address
SocketEOS->SendTo((uint8*)data, size, bytesSent, remoteAddressEOS);
*/
}
Adding a little more info that might help in troubleshooting:
I grabbed the logs from Saved/Logs and filtered to see the lines with “LogEOSSDK:”, which are logged by the EOS plugin- just in case there’s info in these logs that might help to get to the bottom of it.
Bumping this to see if anyone else is seeing something similar in UE5.1 - we upgraded to UE5.1.1, but no change in the issue.
Here are the EOSP2P logs that are triggered at the time the host attempts P2P communication for the first time:
Host:
[2023.02.08-15.53.46:589][619]LogEOSSDK: LogEOSP2P: A new connection closed listener has been bound. LocalUserId=[000…0d8] SocketId=[3cbeb08ddd954721b93ab77bfeca1c26]
[2023.02.08-15.53.46:590][619]LogEOSSDK: LogEOSP2P: Added new peer. LocalUserId=[000…0d8] RemoteUserId=[000…12a]
Client:
[2023.02.08-15.53.46:714][780]LogEOSSDK: LogEOSP2P: Added new peer. LocalUserId=[000…12a] RemoteUserId=[000…0d8]
[2023.02.08-15.53.46:714][780]LogEOSSDK: LogEOSP2P: Received connection invitation request for unknown socket. LocalUserId=[000…12a] RemoteUserId=[000…0d8] SocketId=[3cbeb08ddd954721b93ab77bfeca1c26]
And these messages are logged about a second later:
Host:
[2023.02.08-15.54.26:643][ 15]LogEOSSDK: Warning: LogEOSP2P: Reached maximum send attempts for signal message, will not try further. LocalUserId=[000…0d8] RemoteUserId=[000…12a] MessageId=[0] Type=[com.epicgames.p2p.request_connection] SentTimes=[8/8]
[2023.02.08-15.54.31:602][311]LogEOSSDK: Warning: LogEOSP2P: Removing connection that has timed out. LocalUserId=[000…0d8] RemoteUserId=[000…12a] SocketId=
[3cbeb08ddd954721b93ab77bfeca1c26] SessionGuid=[9R6VmbeRlUWQMD4J9MI8ug]
[2023.02.08-15.54.31:602][311]LogEOSSDK: LogEOSP2P: Removed peer with no connections. LocalUserId=[000…0d8] RemoteUserId=[000…12a]
[2023.02.08-15.54.31:820][432]LogEOSSDK: LogEOSP2P: Received invitation for new Session ID for Socket ID we already know about. LocalUserId=[000…12a] RemoteUserId=[000…0d8] SocketId=[3cbeb08ddd954721b93ab77bfeca1c26] ExistingSessionGuid=[9R6VmbeRlUWQMD4J9MI8ug] NewSessionGuid=[nY43OjGwZUC65kx9Hih0lQ]
[2023.02.08-15.54.31:821][432]LogEOSSDK: LogEOSP2P: Removing existing invitation for new Session ID. LocalUserId=[000…12a] RemoteUserId=[000…0d8] SocketId=[3cbeb08ddd954721b93ab77bfeca1c26] NewSessionGuid=[nY43OjGwZUC65kx9Hih0lQ]
[2023.02.08-15.54.31:821][432]LogEOSSDK: LogEOSP2P: Received connection invitation request for unknown socket. LocalUserId=[000…12a] RemoteUserId=[000…0d8] SocketId=[3cbeb08ddd954721b93ab77bfeca1c26]
[2023.02.08-15.54.31:821][432]LogEOSSDK: LogEOSP2P: Removed peer with no connections. LocalUserId=[000…12a] RemoteUserId=[000…0d8]
It looks like the host tries 8 times to send a signal message to initiate P2P, but the requests don’t go through.
On the client side, we’ve got “Received connection invitation request for unknown socket” and “Received invitation for new Session ID for Socket ID we already know about”. I’m still confused about why this exact setup worked in UE5.0.2, but not in UE5.1
A dev from Epic provided some information in my post on another forum about the same issue. We didn’t quite get to a resolution, but he listed some changes that can be made to the engine to hopefully resolve the problem:
The link above could be a good source for anyone looking for answers- I’m going to mark this post as closed so that the discussion can continue there if needed.