Creating/Joining sessions works fine in packaged build but not in the editor.

I am using the OnlineSubsystem for handling sessions, it works perfectly fine when I package the build and send it to a VM for testing, but this is very tedious to do every time.

I’d it to work inside the editor as well. I’ve seen some videos of people doing this in the editor, but they are using the Advanced Sessions plugin. I’d like to accomplish the same with just the SessionInterface and OnlineSubsystem.

Currently whenever I create or find a session, I set the LAN settings based on if the subsystem is “Null”. The subsystem is always using “Null” inside the editor, so it uses LAN. This is fine for testing the creation / joining.

Creating a session works and returns a success, same for joining. But the SearchResults is always empty in the editor after creating one with a second PIE window, I’m using the standalone 2 player setting.

I’ve asked GPT-4 about this and it could not give me a correct solution. Keep in mind that everything works as intended in a packaged build using steam.

I would really appreciate it if someone knew how to get this to work in the editor.

Here is some of my code:

CreateSession Function:

LastSessionSettings = MakeShared<FOnlineSessionSettings>();
	LastSessionSettings->bIsLANMatch = IOnlineSubsystem::Get()->GetSubsystemName() == "NULL";
	LastSessionSettings->bShouldAdvertise = IOnlineSubsystem::Get()->GetSubsystemName() != "NULL";
	
	LastSessionSettings->NumPublicConnections = 4;
	LastSessionSettings->bUsesPresence = true;
	LastSessionSettings->bAllowJoinViaPresence = true;
	LastSessionSettings->BuildUniqueId = 1;
	LastSessionSettings->bAllowJoinInProgress = true;

FindSession Function:

LastSessionSearch = MakeShared<FOnlineSessionSearch>();
	LastSessionSearch->MaxSearchResults = 10000;
	LastSessionSearch->bIsLanQuery = IOnlineSubsystem::Get()->GetSubsystemName() == "NULL";
	LastSessionSearch->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);

The OnCreateSessionComplete and OnFindSessionsComplete are both called with a success.

The session must be advertised in all cases. Also, I recommend disabling the Run Under One Process param in the editor when testing.