Connect to Steam dedicated server via raw IP?

Hey guys.
The incompatible UniqueId error can be hacked around in the Runtime/Engine/Private/GameModeBase.cpp
line 646 replace
ErrorMessage = TEXT(“incompatible_unique_net_id”);
with
ErrorMessage = GameSession->ApproveLogin(Options);

Since it doesn’t seem to be a lot of info on this I just wanted to add the solution that worked for me in case someone is looking into this.

I did this in the game instance
My game instance inherits from ISteamMatchmakingPingResponse and therefore you need to add an override to

virtual void ServerResponded(gameserveritem_t& server);
virtual void ServerFailedToRespond();

Then implement them like so, I added my own function that I call from blueprint, I pass an IP and port

void UAdvancedFriendsGameInstance::ServerResponded(gameserveritem_t& server)
{
	FString SteamID = FString::Printf(TEXT("%llu"), server.m_steamID.ConvertToUint64());
	PingServerResponse(true, SteamID);
}

void UAdvancedFriendsGameInstance::ServerFailedToRespond()
{
	PingServerResponse(false, "");
}

bool UAdvancedFriendsGameInstance::KaiPingServerInfo(FString IP, int32 Port)
{
	ISteamMatchmakingServers* SteamMCServer = SteamMatchmakingServers();

	if (SteamMCServer != nullptr)
	{
		FIPv4Address OutAddress;
		if (!FIPv4Address::Parse(IP, OutAddress)) return false;
		SteamMCServer->PingServer(OutAddress.Value, (uint16)Port, this);
		return true;
	}

	return false;
}

One thing to note here is you need to use the steam query port which is by default 27015.
Once the response is successful I convert the server ID to a string and then execute a console command, replace STEAMID with the actual server ID.
open steam.STEAMID

That’s basically it. You might get some unresolved externals, you need to add Steamworks and OnlineSubsystemSteam dependecies to your build.cd

In your game instance or wherever you implemented this you might need to include
#include "Private/OnlineSubsystemSteamPrivate.h"