Hello everyone, I’m using the Unreal 5.4 version, I ran into such a problem that I can’t find the created session. Search and create is used from different devices, even using a VPN. But the bottom line is this, initially, when I was just making this system, I could only find my session from one device (a host without a VPN is the one who searches without a VPN), I didn’t like it, I decided to redo it, as a result, the search stopped working for me at all (it works, I see other people’s sessions with errors), but not mine. After 2 days of fruitless attempts to fix something, I saw my first result, I found the first user, unfortunately, it was not my second computer, then he disappeared, after that one person appeared, I found him by nickname on steam and added him as a friend and wrote to him, after that I I also found my account, but after a while, when I tried again, I couldn’t find it. I asked the person I found by nickname to create a session again (he used Advanced Session BP), but unfortunately he also stopped showing up. I don’t know what to do, I need your help
DefaultEngine.ini
[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
[OnlineSubsystem]
DefaultPlatformService=Steam
[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480
bInitServerOnClient=true
[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
I have linked the FindSession and СreateSession functions to the widget buttons
void UMyUserWidgetTEST::NativeConstruct()
{
Super::NativeConstruct();
IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get();
if(OnlineSubsystem && GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, FString::Printf(TEXT("SubSystem name = %s"), *OnlineSubsystem->GetSubsystemName().ToString()));
OnlineSessionPtr = OnlineSubsystem->GetSessionInterface();
}
FNamedOnlineSession* OnlineSession = OnlineSessionPtr->GetNamedSession(NAME_GameSession);
if(OnlineSession != nullptr)
{
OnlineSessionPtr->DestroySession(NAME_GameSession);
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Cyan, FString("All session's clear!"));
}
}
void UMyUserWidgetTEST::CreateSession()
{
if (OnlineSessionPtr.IsValid()) {
FOnlineSessionSettings sessionSettings = FOnlineSessionSettings();
sessionSettings.bIsLANMatch = false;
sessionSettings.NumPublicConnections = 2;
sessionSettings.bShouldAdvertise = true;
sessionSettings.bUsesPresence = true;
sessionSettings.bUseLobbiesIfAvailable = true;
OnlineSessionPtr->CreateSession(0, NAME_GameSession, sessionSettings);
}
}
void UMyUserWidgetTEST::OnSessionCreated(FName InSessionName, bool InWasCreated)
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Cyan, FString::Printf(TEXT("InSessionName = %s, InWasCreated=%d"), *InSessionName.ToString(), InWasCreated));
}else
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Cyan, FString("Sesion not created!"));
}
}
void UMyUserWidgetTEST::OnFindSessionsComplete(bool bWasSuccessful)
{
if (bWasSuccessful && OnlineSessionSearch->SearchResults.Num() > 0)
{
UE_LOG(LogTemp, Log, TEXT("Found %d sessions"), OnlineSessionSearch->SearchResults.Num());
for (const FOnlineSessionSearchResult& SearchResult : OnlineSessionSearch->SearchResults)
{
FString SessionName = SearchResult.GetSessionIdStr();
FString HostUserName = SearchResult.Session.OwningUserName;
int32 CurrentPlayers = SearchResult.Session.SessionSettings.NumPublicConnections - SearchResult.Session.NumOpenPublicConnections;
int32 MaxPlayers = SearchResult.Session.SessionSettings.NumPublicConnections;
UE_LOG(LogTemp, Log, TEXT("Session: %s | Host: %s | Players: %d/%d"), *SessionName, *HostUserName, CurrentPlayers, MaxPlayers);
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("No sessions found or search failed"));
}
OnlineSessionPtr->OnFindSessionsCompleteDelegates.RemoveAll(this);
}
void UMyUserWidgetTEST::FindSession()
{
OnlineSessionSearch = MakeShareable(new FOnlineSessionSearch);
OnlineSessionSearch->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
OnlineSessionSearch->bIsLanQuery = false;
OnlineSessionSearch->MaxSearchResults = 100;
if (OnlineSessionPtr)
{
OnlineSessionPtr->OnFindSessionsCompleteDelegates.AddUObject(this, &UMyUserWidgetTEST::OnFindSessionsComplete);
OnlineSessionPtr->FindSessions(0, OnlineSessionSearch.ToSharedRef());
}
}
logs after CreateFunction:
[2024.08.29-21.19.28:905][442]LogOnlineSession: Verbose: OSS: dumping NamedSession:
[2024.08.29-21.19.28:905][442]LogOnlineSession: Verbose: OSS: SessionName: GameSession
[2024.08.29-21.19.28:906][443]LogOnlineSession: Verbose: OSS: HostingPlayerNum: 0
[2024.08.29-21.19.28:907][443]LogOnlineSession: Verbose: OSS: SessionState: Pending
[2024.08.29-21.19.28:908][443]LogOnlineSession: Verbose: OSS: RegisteredPlayers:
[2024.08.29-21.19.28:908][443]LogOnlineSession: Verbose: OSS: 0 registered players
[2024.08.29-21.19.28:909][443]LogOnlineSession: Verbose: OSS: dumping Session:
[2024.08.29-21.19.28:909][443]LogOnlineSession: Verbose: OSS: OwningPlayerName: MyNic
[2024.08.29-21.19.28:910][444]LogOnlineSession: Verbose: OSS: OwningPlayerId: MyNic
[2024.08.29-21.19.28:911][444]LogOnlineSession: Verbose: OSS: NumOpenPrivateConnections: 0
[2024.08.29-21.19.28:911][444]LogOnlineSession: Verbose: OSS: NumOpenPublicConnections: 1
[2024.08.29-21.19.28:912][444]LogOnlineSession: Verbose: OSS: SessionInfo: HostIP: INVALID SteamP2P: 76561198309282988:7777 Type: Lobby session SessionId: Lobby[0x186000040BCE73F]
[2024.08.29-21.19.28:913][444]LogOnlineSession: Verbose: OSS: dumping SessionSettings:
[2024.08.29-21.19.28:913][444]LogOnlineSession: Verbose: OSS: NumPublicConnections: 2
[2024.08.29-21.19.28:914][444]LogOnlineSession: Verbose: OSS: NumPrivateConnections: 0
[2024.08.29-21.19.28:914][444]LogOnlineSession: Verbose: OSS: bIsLanMatch: false
[2024.08.29-21.19.28:915][444]LogOnlineSession: Verbose: OSS: bIsDedicated: false
[2024.08.29-21.19.28:915][444]LogOnlineSession: Verbose: OSS: bUsesStats: false
[2024.08.29-21.19.28:916][445]LogOnlineSession: Verbose: OSS: bShouldAdvertise: true
[2024.08.29-21.19.28:917][445]LogOnlineSession: Verbose: OSS: bAllowJoinInProgress: false
[2024.08.29-21.19.28:917][445]LogOnlineSession: Verbose: OSS: bAllowInvites: false
[2024.08.29-21.19.28:918][445]LogOnlineSession: Verbose: OSS: bUsesPresence: true
[2024.08.29-21.19.28:918][445]LogOnlineSession: Verbose: OSS: bAllowJoinViaPresence: false
[2024.08.29-21.19.28:919][445]LogOnlineSession: Verbose: OSS: bAllowJoinViaPresenceFriendsOnly: false
[2024.08.29-21.19.28:919][445]LogOnlineSession: Verbose: OSS: BuildUniqueId: 0x01f83457
[2024.08.29-21.19.28:920][445]LogOnlineSession: Verbose: OSS: Settings:
I will add that I see some lobbies when searching, but they are erroneous, as I understand it, pirates use them for their games:
[2024.08.29-21.19.30:813][767]LogOnlineSession: STEAM: Found 49 lobbies, finalizing the search
[2024.08.29-21.19.30:813][767]LogOnlineSession: STEAM: Search result 0: LobbyId=Lobby[0x18600004047CC93], LobbyId.IsValid()=true, CSteamID(LobbyId).IsLobby()=true
[2024.08.29-21.19.30:814][767]LogOnlineSession: Warning: STEAM: Unable to parse search result for lobby 'Lobby[0x18600004047CC93]'
[2024.08.29-21.19.30:816][767]LogOnlineSession: STEAM: Search result 1: LobbyId=Lobby[0x186000040BCE5A1], LobbyId.IsValid()=true, CSteamID(LobbyId).IsLobby()=true
[2024.08.29-21.19.30:817][767]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x0182f6ad, GetBuildUniqueId() = 0x01f83457
[2024.08.29-21.19.30:817][767]LogOnlineSession: Warning: STEAM: Unable to parse search result for lobby 'Lobby[0x186000040BCE5A1]'
[2024.08.29-21.19.30:818][767]LogOnlineSession: STEAM: Search result 2: LobbyId=Lobby[0x18600004063E827], LobbyId.IsValid()=true, CSteamID(LobbyId).IsLobby()=true
[2024.08.29-21.19.30:819][767]LogOnlineSession: Warning: STEAM: Unable to parse search result for lobby 'Lobby[0x18600004063E827]'
[2024.08.29-21.19.30:820][767]LogOnlineSession: STEAM: Search result 3: LobbyId=Lobby[0x186000040AD2045], LobbyId.IsValid()=true, CSteamID(LobbyId).IsLobby()=true
[2024.08.29-21.19.30:821][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data allowrespawn True
[2024.08.29-21.19.30:822][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key allowrespawn value True
[2024.08.29-21.19.30:822][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data allowspectating True
[2024.08.29-21.19.30:823][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key allowspectating value True
[2024.08.29-21.19.30:823][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data contentpackage Vanilla
[2024.08.29-21.19.30:824][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key contentpackage value Vanilla
[2024.08.29-21.19.30:825][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data contentpackagehash D0E38254DD22C1899F0DA45670E30BCA
[2024.08.29-21.19.30:825][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key contentpackagehash value D0E38254DD22C1899F0DA45670E30BCA
[2024.08.29-21.19.30:826][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data eoscrossplay False
[2024.08.29-21.19.30:826][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key eoscrossplay value False
[2024.08.29-21.19.30:827][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data friendlyfireenabled True
[2024.08.29-21.19.30:827][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key friendlyfireenabled value True
[2024.08.29-21.19.30:830][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data gamemode sandbox
[2024.08.29-21.19.30:831][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key gamemode value sandbox
[2024.08.29-21.19.30:831][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data gamestarted False
[2024.08.29-21.19.30:832][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key gamestarted value False
[2024.08.29-21.19.30:832][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data haspassword True
[2024.08.29-21.19.30:833][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key haspassword value True
[2024.08.29-21.19.30:834][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data karmaenabled False
[2024.08.29-21.19.30:834][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key karmaenabled value False
[2024.08.29-21.19.30:835][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data language Russian
[2024.08.29-21.19.30:836][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key language value Russian
[2024.08.29-21.19.30:836][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data lobbyowner STEAM_1:0:778658430
[2024.08.29-21.19.30:837][767]LogOnlineSession: Warning: STEAM: Failed to parse setting from key lobbyowner value STEAM_1:0:778658430
[2024.08.29-21.19.30:838][767]LogOnlineSession: Warning: STEAM: Unknown or unsupported data type from Steam key data maxplayers 2
[2024.08.29-21.19.30:838][768]LogOnlineSession: Warning: STEAM: Failed to parse setting from key maxplayers value 2
.....