OnLoginCompleteDelegates: fires when running standalone, but not when I run play in editor

There might be a reason why this only works in standalone, but maybe there’s a workaround?

I run this code to log in to the Epic Online Services, using the Epic Online Services Online Subsystem Plugin:

void UMyGISubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
	Super::Initialize(Collection);

	const IOnlineIdentityPtr OSSIdentity = Online::GetIdentityInterfaceChecked(FName(TEXT("EOS")));
	
	// login handler
	
	if(OSSIdentity->OnLoginCompleteDelegates->IsBound())
	{
		UE_LOG(LogNet, Warning, TEXT("%s: OnLoginCompleteDelegates: was bound, clearing"), *GetFullName())
		OSSIdentity->OnLoginCompleteDelegates->Clear();
	}
	OSSIdentity->OnLoginCompleteDelegates->AddLambda([this] (int32 LocalUserNum, bool bSuccess, const FUniqueNetId& NewUNI, const FString& Error)
	{
		UE_LOG
			( LogNet
			, Display
			, TEXT("%s: Login of player num %d: %s")
			, *GetFullName()
			, LocalUserNum
			, bSuccess ? TEXT("success") : TEXT("failure")
			)

		UMyLocalPlayer* LocalPlayer = Cast<UMyLocalPlayer>(GetGameInstance()->GetLocalPlayerByIndex(LocalUserNum));
		AMyHUDMenu* HUDMenu = LocalPlayer->GetPlayerController(GetWorld())->GetHUD<AMyHUDMenu>();
		
		if(bSuccess)
		{
			LocalPlayer->IsLoggedIn = true;
			LocalPlayer->SetCachedUniqueNetId(FUniqueNetIdRepl(NewUNI));
			
			Cast<UMyGameInstance>(GetGameInstance())->SessionConfig.bEnableLAN = false;
			HUDMenu->MenuMultiplayerShow();
		}
		else
		{
			HUDMenu->MessageShow
				( FText::FromString(Error)
				, [HUDMenu] () { HUDMenu->MenuMainShow(); }
				);
		}
	});
    // ...
}

When I run as standalone game, that works fine. I log in using DevAuthTool (but using the epic games website works fine, too), the callback gets executed a couple of seconds later.

When I run Play-in-Editor, I see the log output of some successful log-in, but the the callback never gets executed and thus my log-in status never gets updated.

I’ve had similar issues with Steam OSS (Online Subsystem). So I had to use Identity->AutoLogin() in order to make it work. It depends on which OSS are you using. In non-standalone, there is no initialization for the OSS, and therefore you don’t get the result you want.

In short words, you must use standalone to test online subsystem login features.

What I did is made BAT (for Windows) and SH (for MacOS) files that I use to run game directly when I want to test these stuff. Here is the code for those, in case you want to use them too.

BAT file
"C:\your_ue_path\UE4Editor.exe" "C:\your_project path\YourProject.uproject" -game -ResX=1920 -ResY=1080 -WinX=0 -WinY=0 -log

SH file

#! /bin/sh
UE_PATH='/Users/Shared/Epic Games/UE_4.27/Engine/Binaries/Mac/UE4Editor.app'
PROJECT_PATH='/your_project_path/YourProject.uproject'
open -a "$UE_PATH" --args "$PROJECT_PATH" -game -log
2 Likes