Why is my EOS `CreateSession` always unsuccessful?

I tried to host my game on EOS platform, but `FOnlineSessionEOS::CreateSession` is always unsuccessful, as `OnCreateSessionComplete` always says `bWasSuccessful` is `false`.

Relevant code:

int UMultiplayerSessionsSubsystem::CreateSession(int32 NumPublicConnections, FString MatchType, FString PathToLobby_)
{
	if (!OnlineSessionInterface.IsValid())
	{
		UE_LOG(LogTemp, Error, TEXT("OnlineSessionInterface is invalid"));
		return -1;
	}

	PathToLobby = PathToLobby_;

	auto ExistingSession = OnlineSessionInterface->GetNamedSession(NAME_GameSession);
	if (ExistingSession != nullptr)
	{
		OnlineSessionInterface->DestroySession(NAME_GameSession);
	}

	OnlineSessionInterface->AddOnCreateSessionCompleteDelegate_Handle(CreateSessionCompleteDelegate);

	TSharedPtr<FOnlineSessionSettings> SessionSettings = MakeShared<FOnlineSessionSettings>();
	if (!SessionSettings.IsValid())
	{
		UE_LOG(LogTemp, Error, TEXT("SessionSettings is invalid"));
		return -1;
	}
	SessionSettings->bIsDedicated = false;
	SessionSettings->bIsLANMatch = false;
	SessionSettings->NumPublicConnections = NumPublicConnections;
	SessionSettings->bAllowJoinInProgress = true;
	SessionSettings->bAllowJoinViaPresence = true;
	SessionSettings->bShouldAdvertise = true;
	SessionSettings->bUsesPresence = true;
	SessionSettings->bUseLobbiesIfAvailable = true;
	SessionSettings->bUseLobbiesVoiceChatIfAvailable = true;
	SessionSettings->bAllowInvites = true;
	SessionSettings->Set(FName("MatchType"), MatchType, EOnlineDataAdvertisementType::ViaOnlineServiceAndPing);

	/*UWorld* World = GetWorld();
	if (World == nullptr)
	{
		UE_LOG(LogTemp, Error, TEXT("World is invalid"));
		return -1;
	}
	const ULocalPlayer* LocalPlayer = World->GetFirstLocalPlayerFromController();
	if (LocalPlayer == nullptr)
	{
		UE_LOG(LogTemp, Error, TEXT("LocalPlayer is invalid"));
		return -1;
	}
	FUniqueNetIdRepl UniqueNetId = LocalPlayer->GetPreferredUniqueNetId();*/
	if (!UniqueNetId.IsValid())
	{
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(
				-1,
				15.f,
				FColor::Red,
				FString(TEXT("UniqueNetId is invalid"))
			);
		}
		UE_LOG(LogTemp, Error, TEXT("UniqueNetId is invalid"));
		return -1;
	}
	if (!OnlineSessionInterface->CreateSession(*UniqueNetId, NAME_GameSession, *SessionSettings))
	{
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(
				-1,
				15.f,
				FColor::Red,
				FString(TEXT("Failed to create session!"))
			);
		}
		UE_LOG(LogTemp, Warning, TEXT("Failed to create session!"));
		return -1;
	}
	return 0;
}

void UMultiplayerSessionsSubsystem::OnCreateSessionComplete(FName SessionName, bool bWasSuccessful)
{
	if (bWasSuccessful)
	{
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(
				-1,
				15.f,
				FColor::Blue,
				FString::Printf(TEXT("Created session: %s"), *(SessionName.ToString()))
			);
		}
		UE_LOG(LogTemp, Warning, TEXT("Created session: %s"), *(SessionName.ToString()));

		UWorld* World = GetWorld();
		if (World == nullptr)
		{
			UE_LOG(LogTemp, Error, TEXT("World is invalid"));
			return;
		}
		World->ServerTravel(PathToLobby, true, true);
	}
	else
	{
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(
				-1,
				15.f,
				FColor::Red,
				FString(TEXT("Failed to create session!"))
			);
		}
		UE_LOG(LogTemp, Error, TEXT("Failed to create session!"));
	}
}

068QP00000ndqylYAA.cpp (11.6 KB)
068QP00000ndUA8YAM.h (2.68 KB)

Hello,

There should be a log message in LogOnline, LogOnlineSession or LogEOSSDK to help you pin point the issue.

Thanks,

Seb