Download

Cannot re-join WAN game after end of match on Steam. [U.E. - 4.15]

Hello everyone,

I have encountered a problem with the Steam online subsystem that I cannot figure out for the life of me. I have looked online at countless sources on unreal engine forums, but this seems to lie within the engine code and the posts made for this issue are pretty old. This is not a problem at all with LAN, as it works perfectly to rejoin the session by someone who hosted last time.

A workout I discovered with Steam though is that you can alternate Host and Joining fine. So, if one machine hosts one game and then that same machine joins the game of another after the match is done, it works. However, if you keep the machines that hosted and joined from last game, it won’t work for the client to join.

I debugged the engine code and the state becomes FAILED after the second time of joining a game. The joining system is pretty much exactly how the shooter game handles it. I remember hearing that they had a similar issue.

I would like to know if anyone has ever had this issue, or if anyone has any suggestions with how to proceed. I could edit the engine code but I want to refrain from doing that. I was thinking maybe this is a limitation with using the DevApp ID (Spacewars) and maybe not an issue on shipped release of the game on Steam. But, obviously, I would like to be able to test it without doing that. So, if anybody has any suggestions, I’m all ears.

Not sure if that would cause the exact symptoms of your issue, but I experienced a similar problem which was caused by the session not being closed after leaving a match. So a quick way to fix this is to call DestroySession when the main menu is loaded for example or before you join a new session.

I called “CleanupSessionOnReturnToMenu” right after the game ends, and sends you back to the previous level. This is a method in ShooterGame that looks like this:



void UShooterGame::CleanupSessionOnReturnToMenu() {

// end online game and then destroy it
IOnlineSubsystem * OnlineSub = IOnlineSubsystem::Get();
IOnlineSessionPtr Sessions = (OnlineSub != NULL) ? OnlineSub->GetSessionInterface() : NULL;

if (Sessions.IsValid())
{
   EOnlineSessionState::Type SessionState = Sessions->GetSessionState(GameSessionName);
   UE_LOG(CDLogOnline, Log, TEXT("Session %s is '%s'"), *GameSessionName.ToString(), EOnlineSessionState::ToString(SessionState));

   if (EOnlineSessionState::InProgress == SessionState)
   {
   UE_LOG(CDLogOnline, Log, TEXT("Ending session %s on return to main menu"), *GameSessionName.ToString());
OnEndSessionCompleteDelegateHandle = Sessions->AddOnEndSessionCompleteDelegate_Handle(OnEndSessionCompleteDelegate);
Sessions->EndSession(GameSessionName);
   }
   else if (EOnlineSessionState::Ending == SessionState)
   {
UE_LOG(CDLogOnline, Log, TEXT("Waiting for session %s to end on return to main menu"), *GameSessionName.ToString());
OnEndSessionCompleteDelegateHandle = Sessions->AddOnEndSessionCompleteDelegate_Handle(OnEndSessionCompleteDelegate);
   }
   else if (EOnlineSessionState::Ended == SessionState || EOnlineSessionState::Pending == SessionState)
   {
     UE_LOG(CDLogOnline, Log, TEXT("Destroying session %s on return to main menu"), *GameSessionName.ToString());
OnDestroySessionCompleteDelegateHandle = Sessions->AddOnDestroySessionCompleteDelegate_Handle(OnEndSessionCompleteDelegate);
Sessions->DestroySession(GameSessionName);
   }
   else if (EOnlineSessionState::Starting == SessionState)
   {
      UE_LOG(CDLogOnline, Log, TEXT("Waiting for session %s to start, and then we will end it to return to main menu"), *GameSessionName.ToString());
      OnStartSessionCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(OnEndSessionCompleteDelegate);
    }
  }
}
 

This seems to work fine for LAN - had no issues so far- but seems to be an issue for WAN. I am going to debug and see what the status is, but I’m pretty sure some state is not handled properly here in the WAN code.

I found the issue, I just wasn’t closing the session on the client…