Client Disconnect

I am trying to handle when a client disconnects from a server (via a system crash/network failure) but can’t seem to find any callbacks that are called when the client disconnects. Is there a callback or some kind of handle for the host to know when a client has lost connection?

I’ve tried OnNetworkFailure functions which does give information back to the client if a host quits but doesn’t seem to work for the host/server.

Hmmm couldn’t find anything on this too. Any help?

try Overriding PlayerState::OnDeactivated

Perhaps using EndPlay will help?

AActor::EndPlay()

More details here: AActor::EndPlay | Unreal Engine Documentation

It at least provides a reason for the end. Although, it doesn’t say if they client disconnected, but would at least say if/when they were removed from the level.

In GameMode there is a Logout() and OnLogout() that is called when a player exits game. You can also override the Destroyed() function of the PlayerController.

Sorry, this is server side only

This is still server side.

It doesn’t work. When your client is disconnected from the server, the engine will try to reconnect within a certain time. During this time, actors are not destroyed. Even though the connection is down, actors still stay.

All what I need is to display something to the player when disconnection happens.

in GameInstance, there is a function can override in blueprint
HandleNetworkError

this maybe you want

Destroy Session when you start your Main Menu Map, that way when they get booted from the game the client can find a new session. If the Session is not destroyed the can’t find any other sessions, or join them when he gets booted from a session, or if the server crashes.