How to handle a Join Session error in C++?


I’m trying to handle the situation where a player has found a session to join and starts to join it, but the host of that session (or the dedicated server) closes down a moment before they join.

In Blueprints, I believe the Join Session node has an “On Failure” execution pin to handle this, but what is the equivalent delegate/callback that I can use in C++? Thanks.

Every time I post here I find out an answer like an hour later… :stuck_out_tongue: Anyway, I’ll post the answer here in case it helps some future traveler. You can bind a function to the Engine event called “OnNetworkFailure()”. I’m doing it in my GameInstance class like this:

GetEngine()->OnNetworkFailure().AddUObject(this, &UMGGameInstance::HandleNetworkFailure);

And the parameters for your bound function should be like this:

HandleNetworkFailure(UWorld World, UNetDriver NetDriver, ENetworkFailure::Type FailureType, const FString& ErrorString)**

Now I can implement the function and check the FailureType to handle things like ConnectionTimeout and ConnectionLost. And later on, whatever other Network Error I want. That’s all there is to it!

I’ve also implemented your solution, but I still cannot control clientTraveling to the EntryMap.
How do you choose whether/where the client will travel to post-NetworkError?

1 Like