How to cancel Client Traveling ?

I created a function in C++ to make the client connect to a server by IP :

if (GetGameInstance() && GetGameInstance()->GetFirstLocalPlayerController())
		GetGameInstance()->GetFirstLocalPlayerController()->ClientTravel("192.168.22.31", ETravelType::TRAVEL_Absolute);

the issue here is if the server is not running, it keep trying to connect, here’s the log :
LogNet: Initial Connect Diagnostics: Sent '9' packets in last '10.004943' seconds, no packets received yet.

How do i cancel that ?

I found the solution if someone is interested in it, if you go to PostInitProperties function in NetDriver.cpp you will find :

#if WITH_EDITOR
		// Do not time out in PIE since the server is local.
		bNoTimeouts = bNoTimeouts || (GEditor && GEditor->PlayWorld);
#endif // WITH_EDITOR

to solve this issue you must modify this line and build the engine.

1 Like