Steam Dedicated Server crashing

Hey everyone,

I am trying to build a dedicated server, however I am getting a crash whenever I try to create a session through Steam. I got no idea why this happens and have already tried going through all posts describing the same issue. Also, bUsePresence is set to false.

I am using 5.1 version of the engine.

I am calling the create session on GameMode BeginPlay like this:

void AMenuGameMode::BeginPlay()
{
	Super::BeginPlay();

	bool bIsDedicatedServer = UKismetSystemLibrary::IsDedicatedServer(this);
	if (bIsDedicatedServer)
	{
		UGameInstance* GameInstance = GetGameInstance();
		if (GameInstance)
		{
			UMultiplayerSessionsSubsystem* MultiplayerSessionsSubsystem = GameInstance->GetSubsystem<UMultiplayerSessionsSubsystem>();
			if (MultiplayerSessionsSubsystem)
			{
				MultiplayerSessionsSubsystem->CreateSession(10, FString("FreeForAll"));
			}
		}
	}
}

and then this is how I create a session in MultiplayerSessionsSubsystem::CreateSession:

UMultiplayerSessionsSubsystem::UMultiplayerSessionsSubsystem():
	CreateSessionCompleteDelegate(FOnCreateSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnCreateSessionComplete)),
	FindSessionsCompleteDelegate(FOnFindSessionsCompleteDelegate::CreateUObject(this, &ThisClass::OnFindSessionsComplete)),
	JoinSessionCompleteDelegate(FOnJoinSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnJoinSessionComplete)),
	DestroySessionCompleteDelegate(FOnDestroySessionCompleteDelegate::CreateUObject(this, &ThisClass::OnDestroySessionComplete)),
	StartSessionCompleteDelegate(FOnStartSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnStartSessionComplete))
{
	IOnlineSubsystem* Subsystem = IOnlineSubsystem::Get();
	if (Subsystem)
	{
		SessionInterface = Subsystem->GetSessionInterface();
	}
}

void UMultiplayerSessionsSubsystem::CreateSession(int32 NumPublicConnections, FString MatchType)
{
	if (!SessionInterface.IsValid())
	{
		return;
	}

	auto ExistingSession = SessionInterface->GetNamedSession(NAME_GameSession);
	if (ExistingSession != nullptr)
	{
		bCreateSessionOnDestroy = true;
		LastNumPublicConnections = NumPublicConnections;
		LastMatchType = MatchType;

		DestroySession();
	}

	CreateSessionCompleteDelegateHandle = SessionInterface->AddOnCreateSessionCompleteDelegate_Handle(CreateSessionCompleteDelegate);

	LastSessionSettings = MakeShareable(new FOnlineSessionSettings());
	LastSessionSettings->bIsLANMatch = IOnlineSubsystem::Get()->GetSubsystemName() == "NULL" ? true : false;
	LastSessionSettings->NumPublicConnections = NumPublicConnections;
	LastSessionSettings->bAllowJoinInProgress = true;
	LastSessionSettings->bAllowJoinViaPresence = false;
	LastSessionSettings->bShouldAdvertise = true;
	LastSessionSettings->bUsesPresence = false;
	LastSessionSettings->Set(FName("MatchType"), MatchType, EOnlineDataAdvertisementType::ViaOnlineServiceAndPing);
	LastSessionSettings->BuildUniqueId = 1;
	LastSessionSettings->bUseLobbiesIfAvailable = true;
	
	SessionInterface->CreateSession(0, NAME_GameSession, *LastSessionSettings);
}

Here is the crashlog:

[2023.02.08-17.24.31:061][ 28]LogThreadingWindows: Error: Runnable thread OnlineAsyncTaskThreadSteam DefaultInstance crashed.
[2023.02.08-17.24.31:061][ 28]LogWindows: Error: === Critical error: ===
[2023.02.08-17.24.31:061][ 28]LogWindows: Error: 
[2023.02.08-17.24.31:062][ 28]LogWindows: Error: Assertion failed: SteamUtilsPtr [File:C:\Users\nikgi\Documents\GitHub Desktop\UE_5.1_SC\Engine\Plugins\Online\OnlineSubsystemSteam\Source\Private\OnlineSessionAsyncLobbySteam.cpp] [Line: 473] 
[2023.02.08-17.24.31:062][ 28]LogWindows: Error: 
[2023.02.08-17.24.31:062][ 28]LogWindows: Error: 
[2023.02.08-17.24.31:062][ 28]LogWindows: Error: 
[2023.02.08-17.24.31:063][ 28]LogWindows: Error: [Callstack] 0x00007ff660333324 MyProjectServer.exe!FOnlineAsyncTaskSteamCreateLobby::Tick() [C:\Users\nikgi\Documents\GitHub Desktop\UE_5.1_SC\Engine\Plugins\Online\OnlineSubsystemSteam\Source\Private\OnlineSessionAsyncLobbySteam.cpp:473]
[2023.02.08-17.24.31:063][ 28]LogWindows: Error: [Callstack] 0x00007ff6602cdf81 MyProjectServer.exe!FOnlineAsyncTaskManager::Tick() [C:\Users\nikgi\Documents\GitHub Desktop\UE_5.1_SC\Engine\Plugins\Online\OnlineSubsystem\Source\Private\OnlineAsyncTaskManager.cpp:397]
[2023.02.08-17.24.31:063][ 28]LogWindows: Error: [Callstack] 0x00007ff6602c535d MyProjectServer.exe!FOnlineAsyncTaskManager::Run() [C:\Users\nikgi\Documents\GitHub Desktop\UE_5.1_SC\Engine\Plugins\Online\OnlineSubsystem\Source\Private\OnlineAsyncTaskManager.cpp:78]
[2023.02.08-17.24.31:063][ 28]LogWindows: Error: [Callstack] 0x00007ff662c6a422 MyProjectServer.exe!FRunnableThreadWin::Run() [C:\Users\nikgi\Documents\GitHub Desktop\UE_5.1_SC\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:149]
[2023.02.08-17.24.31:063][ 28]LogWindows: Error: [Callstack] 0x00007ff662c6217a MyProjectServer.exe!FRunnableThreadWin::GuardedRun() [C:\Users\nikgi\Documents\GitHub Desktop\UE_5.1_SC\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:79]
[2023.02.08-17.24.31:063][ 28]LogWindows: Error: [Callstack] 0x00007ffee05f26bd KERNEL32.DLL!UnknownFunction []
[2023.02.08-17.24.31:065][ 28]LogWindows: Error: [Callstack] 0x00007ffee260dfb8 ntdll.dll!UnknownFunction []
[2023.02.08-17.24.31:065][ 28]LogWindows: Error: 
[2023.02.08-17.24.31:065][ 28]LogWindows: Error: Crash in runnable thread OnlineAsyncTaskThreadSteam DefaultInstance
[2023.02.08-17.24.31:071][ 28]LogExit: Executing StaticShutdownAfterError
[2023.02.08-17.24.31:071][ 28]LogWindows: FPlatformMisc::RequestExit(1)
[2023.02.08-17.24.31:071][ 28]LogWindows: FPlatformMisc::RequestExitWithStatus(1, 3)
[2023.02.08-17.24.31:072][ 28]LogCore: Engine exit requested (reason: Win RequestExit)

Anyone helping me out with this would be great as I am stuck for hours. Thanks!

1 Like

Managed to solve the issue with setting these flags:

LastSessionSettings->bUseLobbiesIfAvailable = false;
LastSessionSettings->bIsDedicated = true;

Reference to post that helped me: Dedicated Server Crash