Not able to find lobby

Everything is fine, but FindSession is not able to find any session.

Log:-

[2022.09.10-16.23.40:081][962]LogTemp: Warning: Starting to find sessions!
[2022.09.10-16.23.41:005][146]LogOnlineSession: Warning: STEAM: Server response IP:37.10.126.113
[2022.09.10-16.23.41:022][149]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:162][177]LogOnlineSession: Warning: STEAM: Server response IP:85.215.176.226
[2022.09.10-16.23.41:162][177]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:202][185]LogOnlineSession: Warning: STEAM: Server response IP:20.151.66.71
[2022.09.10-16.23.41:202][185]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:242][193]LogOnlineSession: Warning: STEAM: Server response IP:20.151.66.71
[2022.09.10-16.23.41:242][193]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:262][197]LogOnlineSession: Warning: STEAM: Server response IP:34.78.226.104
[2022.09.10-16.23.41:262][197]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:462][237]LogOnlineSession: Warning: STEAM: Server response IP:8.142.106.102
[2022.09.10-16.23.41:463][237]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:464][237]LogOnline: Verbose: OSS: Async task 'FOnlineAsyncTaskSteamFindServers bWasSuccessful: 1 Results: 0' succeeded in 1.361377 seconds
[2022.09.10-16.23.41:464][237]LogTemp: Warning: Finished Find Sessions!

GameInstance.CPP -

// Fill out your copyright notice in the Description page of Project Settings.

#include "PuzzlePlatformsGameInstance.h"

#include "Engine/Engine.h"

#include "OnlineSessionSettings.h"

#include "OnlineSubsystem.h"

#include "UObject/ConstructorHelpers.h"

#include "Blueprint/UserWidget.h"

#include "MenuSystem/InGameMenu.h"

#include "MenuSystem/MainMenu.h"

#define OUT

const static FName SESSION_NAME = TEXT("My Session Game"); //Gloable Name For Creating Session

UPuzzlePlatformsGameInstance::UPuzzlePlatformsGameInstance(const FObjectInitializer & ObjectInitializer)

{

    static ConstructorHelpers::FClassFinder<UUserWidget> BPMenuWidget(TEXT("/Game/MenuSystem/WBP_MainMenu")); //Getting the address of Blueprint Menu Widget

    if(!BPMenuWidget.Succeeded()) return;

    MainMenuClass = BPMenuWidget.Class;

    static ConstructorHelpers::FClassFinder<UUserWidget> BPInGameMenuWidget(TEXT("/Game/MenuSystem/WBP_InGameMenu")); //Getting the address of Blueprint Menu Widget

    if(!BPInGameMenuWidget.Succeeded()) return;

    InGameMenuClass = BPInGameMenuWidget.Class;

}

void UPuzzlePlatformsGameInstance::Init()

{

    IOnlineSubsystem* Subsystem = IOnlineSubsystem::Get();

    if(Subsystem)

    {

        UE_LOG(LogTemp, Warning, TEXT("Subsystem Name:- %s"), *Subsystem->GetSubsystemName().ToString()); //Debug Line to check the name of SubSystem

        SessionInterface = Subsystem->GetSessionInterface();

        if(SessionInterface.IsValid())

        {

            SessionInterface->OnCreateSessionCompleteDelegates.AddUObject(this, &UPuzzlePlatformsGameInstance::OnCreateSessionComplete);

            SessionInterface->OnDestroySessionCompleteDelegates.AddUObject(this, &UPuzzlePlatformsGameInstance::OnDestroySessionComplete);

            SessionInterface->OnFindSessionsCompleteDelegates.AddUObject(this, &UPuzzlePlatformsGameInstance::OnFindSessionsComplete);

            SessionInterface->OnJoinSessionCompleteDelegates.AddUObject(this, &UPuzzlePlatformsGameInstance::OnJoinSessionComplete);

        }

    }

}

void UPuzzlePlatformsGameInstance::CreateSession()

{

    if(!SessionInterface.IsValid()) return;

   

    //Session Settings

    FOnlineSessionSettings SessionSetting;

    SessionSetting.bShouldAdvertise = true; //Shoud be able to be found when using FindSession Function

    SessionSetting.NumPublicConnections = 2; //Total no. of player in this session

    SessionSetting.bIsLANMatch = false; //Is this session going to be visible only for Same lan connected Devices?

    SessionSetting.bUsesPresence = true;

    SessionSetting.bUseLobbiesIfAvailable = true;

    SessionInterface->CreateSession(0, SESSION_NAME, SessionSetting);

}

void UPuzzlePlatformsGameInstance::OnCreateSessionComplete(FName SessionName, bool bSuccess)

{

    if(!bSuccess)

    {

        return;

    }

    UWorld* World = GetWorld();

    if(!World) return;

    World->ServerTravel("/Game/Levels/PuzzlePlatformLevel?listen", ETravelType::TRAVEL_Absolute); //Travel to playeble level

    if(MainMenuWidget)

    {

        MainMenuWidget->TearDownMenu(); //Tear Down the main menu

    }

}

void UPuzzlePlatformsGameInstance::OnDestroySessionComplete(FName SessionName, bool bSuccess)

{

    if(!bSuccess)

    {

        return;

    }

    CreateSession(); //After deleting old session

}

void UPuzzlePlatformsGameInstance::OnFindSessionsComplete(bool bSuccess)

{

    if(!bSuccess) return;

    UE_LOG(LogTemp, Warning, TEXT("Finished Find Sessions!"));

    if(!SessionSearch || !MainMenuWidget) return;

    TArray<FOnlineSessionSearchResult> SessionsList = SessionSearch->SearchResults; // all search results

    TArray<FString> ServerNames;

    for (FOnlineSessionSearchResult Session : SessionsList) //Convering founded session's ID to string

    {

        ServerNames.Add(Session.GetSessionIdStr());

    }

    MainMenuWidget->SetServerList(ServerNames); //Calling SetServerList Function form Menu Widget so that menu could update the list of current live servers

}

void UPuzzlePlatformsGameInstance::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type ResultType)

{

    if(ResultType != EOnJoinSessionCompleteResult::Success) return;

    if(!SessionInterface) return;

    FString ConnectInfo;

    bool bCallWorked = SessionInterface->GetResolvedConnectString(SessionName, OUT ConnectInfo);

    if(!bCallWorked) return;

    UEngine* Engine = GetEngine();

    if(Engine)

    {

        Engine->AddOnScreenDebugMessage(0, 2.f, FColor::Green, FString::Printf(TEXT("Joining! Address: %s"), *ConnectInfo));

    }

    APlayerController* Controller = GetFirstLocalPlayerController();

    if(!Controller) return;

    Controller->ClientTravel(ConnectInfo, ETravelType::TRAVEL_Absolute);

   

    if(MainMenuWidget)

    {

        MainMenuWidget->TearDownMenu();

    }

}

void UPuzzlePlatformsGameInstance::RefreshServerList() //Function to find session

{

    if(!SessionInterface) return;

    SessionSearch = MakeShareable(new FOnlineSessionSearch()); //Making shareable FOnlineSessionSearch pointer and assigning it to TSharedPtr SessionSearch

     

    if(SessionSearch.IsValid()) //Making sure session search is not null otherwise we won't be able to convert it to Shared Refrence

    {

        UE_LOG(LogTemp, Warning, TEXT("Starting to find sessions!"));

        SessionSearch->bIsLanQuery = false; //Telling to search only Lan Connected Servers

        SessionSearch->MaxSearchResults = 100;

        SessionSearch->QuerySettings.Set(SESSION_NAME, true, EOnlineComparisonOp::Equals);

        SessionInterface->FindSessions(0, SessionSearch.ToSharedRef()); //Converting TShareedPtr to TSharedRef and Starting to find sessions

    }

}

void UPuzzlePlatformsGameInstance::Host() //function for hosting

{

    if(!SessionInterface.IsValid()) return;

    //Checking if there is any session already created, If yes then first destroy it

    auto ExistingSession = SessionInterface->GetNamedSession(SESSION_NAME);

    if(ExistingSession)

    {

        SessionInterface->DestroySession(SESSION_NAME);

    }

    else

    {

        CreateSession();

    }

   

}

void UPuzzlePlatformsGameInstance::Join(const uint32 Index) //function of joining

{

    if(!SessionInterface || !SessionSearch) return;

    SessionInterface->JoinSession(0, SESSION_NAME, SessionSearch->SearchResults[Index]);

}

void UPuzzlePlatformsGameInstance::LoadInGameMenu() //Display Pause Menu (This function will be called for level blueprint when pressed a specific button)

{

    if(!InGameMenuClass) return;

    InGameMenuWidget = CreateWidget<UInGameMenu>(this, InGameMenuClass); //Creating widget to display

    if(!InGameMenuWidget) return;

    InGameMenuWidget->SetMenuInterface(this);

    InGameMenuWidget->Setup();

}

void UPuzzlePlatformsGameInstance::TravelMainMenuLevel() //Travel to main menu level

{

    UWorld* World = GetWorld();

    if(!World) return;

    World->ServerTravel("/Game/Levels/MainMenuLevel?listen", ETravelType::TRAVEL_Absolute);

}

void UPuzzlePlatformsGameInstance::LoadMenu() //load Main Menu (This function will be called for level blueprint)

{

    if(!MainMenuClass) return; //Bp class of user widget

    MainMenuWidget = CreateWidget<UMainMenu>(this, MainMenuClass); //Creating widget to display

    if(!MainMenuWidget) return;

   

    MainMenuWidget->SetMenuInterface(this); //calling this function from MainMenuClass, setting GameInstance as IMenuInterface

    MainMenuWidget->Setup();

}

NOTE:-

  • Steam is on while playing the game.

  • I tried playing the game with my friend using Packaged Project and Powershell both.

  • I also tried increasing MaxSearchResults to 50k

  • On my friend’s PC, Space War Project is not working. I tried many things, but was not able to run SpaceWar on his PC. I don’t think this should be the reason for not being able to play with my friend.

  • This log is showing on my computer as I host the lobby from my friend’s computer. Verbose: STEAM: FOnlineAsyncEventSteamRichPresenceUpdate got new information about user 76561199072553947

  • When I host the lobby this warning shows in the hosting PC’s log LogOnlineSession: Warning: Steam: No game present to join for session (GameSession)

This could be a firewall issue on your PC. Ensure you compare your code against end of lecture for differences. Let me know how you get on and I’ll try and think of anything else.

Also, looking at the screenshot - this is important. The code has to be identical for both machines running the game. I would recommend a build at first to ensure this is the case.

1 Like

As you said, I compared the code and it is the same. There are some differences, but I made those changes to avoid some bugs, and those changes are for tearing down menu widgets, so I don’t think that the difference in widget function will create any kind of issue while finding lobbies. But if you will say I will also make the code exactly the same as the lecture for testing purposes.

Yes, you also suggested the same thing a while ago, and I did the same thing, using build game and project both. But I still cannot find the sessions and there is also an issue with the build which is I can’t even see the log to know what is going on behind the game.

Well, if so, then please guide me to solve that.

I think you will have to think of something else. I can share my project with you so that you can ensure that there is no issue with my PC or with the project.

I am using this setting for build-

Build Download Link
Project Download Link

Hi, the firewall I cannot guide you with. Its different depending on OS so you have to look that up yourself. It is not something covered in the course.

As for your differences, I can tell you that the course materials work so this means if it not the firewall, something else is wrong, a d it is most likely the code. Try cloning the project from github and see if that works.

I assume here that the steam OSS is initialising correctly.

One last thing, steam is very particular about the region in which players are. All players must be in tbe same region. I believe this was mentioned so I just want to check this is the case.

1 Like

The region is exactly same for both PC. And I will try to clone the project and then test it out. I will let you know how it went.

Yes, you are right. I made a small mistake in my code.

SessionSearch->QuerySettings.Set(First Parameter, true, EOnlineComparisonOp::Equals);
Instead of passing SEARCH_PRESENCE I passed SESSION_NAME

Now my project is working fine. Thanks a lot for your help. :grin:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms