# Why is no sessions being created

**URL:** <https://forums.unrealengine.com/t/why-is-no-sessions-being-created/464159>\
**Category:** Multiplayer & Networking\
**Tags:** onlinesubsystem, lan, sessions, unreal-engine, Multiplayer, CPP, question\
**Created:** [April 24, 2020, 1:48pm UTC](https://forums.unrealengine.com/t/why-is-no-sessions-being-created/464159 "2020-04-24T13:48:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BEnSon1101](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BEnSon1101](https://forums.unrealengine.com/u/BEnSon1101)\
**Post date:** [April 24, 2020, 1:48pm UTC](https://forums.unrealengine.com/t/why-is-no-sessions-being-created/464159/1 "2020-04-24T13:48:19Z")

</div>

**i am trying to run a LAN multiplayer testing session but it wont join session i am using two versions of same game on one PC running standalone is this wrong**

```
void UGameInstance::Init()
{
    if (IOnlineSubsystem* SubSystem = IOnlineSubsystem::Get())
    {
	    SessionInterface = SubSystem->GetSessionInterface();
	    if (SessionInterface.IsValid())
	    {	
		//bind delegates
		SessionInterface->OnCreateSessionCompleteDelegates.AddUObject(this, &UGameInstance::OnCreateSessionComplete);
		SessionInterface->OnFindSessionsCompleteDelegates.AddUObject(this, &UGameInstance::OnFindSessionComplete);
		SessionInterface->OnJoinSessionCompleteDelegates.AddUObject(this, &UGameInstance::OnJoinSessionComplete);
	    }
    }
}

void UGameInstance::OnCreateSessionComplete(FName ServerName, bool Succeeded)
{
    UE_LOG(LogTemp, Warning, TEXT("OnCreateSessionComplete, Succeeded: %d"), Succeeded);
    if (Succeeded)
    {
	    GetWorld()->ServerTravel("/Game/FirstPersonCPP/Maps/FirstPersonExampleMap?listen");
    }
}

void UGameInstance::OnFindSessionComplete(bool Succeeded)
{
    UE_LOG(LogTemp, Warning, TEXT("OnFindSessionComplete, Succeeded: %d"), Succeeded);
    if (Succeeded)
    {
	    TArray<FOnlineSessionSearchResult> SearchResults = SessionSearch->SearchResults;

	    UE_LOG(LogTemp, Warning, TEXT("SearchResults, Server Count: %d"), SearchResults.Num());

	    if (SearchResults.Num())
	    {
		UE_LOG(LogTemp, Warning, TEXT("Joining Server"));
		SessionInterface->JoinSession(0, "My Session", SearchResults[0]);
	    }

    }
}

void UGameInstance::OnJoinSessionComplete(FName SessionName, 
EOnJoinSessionCompleteResult::Type Result)
{
    UE_LOG(LogTemp, Warning, TEXT("OnJoinSessionComplete"));
    if (APlayerController* PController = UGameplayStatics::GetPlayerController(GetWorld(), 0))
    {
	    FString JoinAdress = "";
	    SessionInterface->GetResolvedConnectString(SessionName, JoinAdress);
	if (JoinAdress != "")
		PController->ClientTravel(JoinAdress, ETravelType::TRAVEL_Absolute);
    }
}

void UGameInstance::CreateServer()
{
    UE_LOG(LogTemp, Warning, TEXT("CreateServer"));

    FOnlineSessionSettings SessionSettings;
    SessionSettings.bAllowJoinInProgress = true;
    SessionSettings.bIsDedicated = false;
    SessionSettings.bIsLANMatch = true;
    SessionSettings.bShouldAdvertise = true;
    SessionSettings.NumPrivateConnections = 5;
    SessionSettings.NumPublicConnections = 5;

    SessionInterface->CreateSession(0, FName("My Session"), SessionSettings);
}

void UGameInstance::JoinServer()
{
    UE_LOG(LogTemp, Warning, TEXT("JoinServer"));
    SessionSearch = MakeShareable(new FOnlineSessionSearch());
    SessionSearch->bIsLanQuery = true;
    SessionSearch->MaxSearchResults = 10000;
    SessionSearch->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);

    SessionInterface->FindSessions(0, SessionSearch.ToSharedRef());
}
```

---

<div class="post-metadata">

**Author:** ![BEnSon1101](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BEnSon1101](https://forums.unrealengine.com/u/BEnSon1101)\
**Post date:** [April 26, 2020, 4:15am UTC](https://forums.unrealengine.com/t/why-is-no-sessions-being-created/464159/2 "2020-04-26T04:15:45Z")

</div>

I figured it out **MY SELF!!!** and to all the new developers this is how i fixed it.

**follow this tutorial for more info about sessions**

in your Build.cs put the following instead of what is in the video

```
using UnrealBuildTool;

public class YourGameName: ModuleRules
{
    public YourGameName(ReadOnlyTargetRules Target) : base(Target)
    {
	    PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "OnlineSubsystem", "OnlineSubsystemNull", "OnlineSubsystemUtils" });

        PrivateDependencyModuleNames.AddRange(new string[] { });

        PrivateDependencyModuleNames.Add("OnlineSubsystem");
        PrivateDependencyModuleNames.Add("OnlineSubsystemNull");
    }
}
```
