メインコンテンツまでスキップ

How to Handle Friend List Connection Errors

Last updated on February 27, 2025

Handling errors like connection timeouts when retrieving a friend list is crucial for maintaining a smooth player experience. If a player tries to view their friends list and the game encounters a connection issue, proper error handling ensures that the player isn’t left wondering why the list isn't updating. Here are several effective approaches to handle this issue:

  • Show a Friendly Error Message. If there is an error while retrieving the friend list, you could display a clear and friendly error message based on the error value and message of the HTTP response.
  • Manual Retry Option. Offer the player an option to manually retry fetching the friend list.
  • Polling the friend list for certain interval, such as every 60 seconds. Please be aware that this mechanism could strain the AGS social service!
  • Caching the friend list after updating the list.

If the retrieving friend list request error is not handled properly, the game might encounter several issues that negatively impact the player experience. Here are some examples:

  • Infinite retrieving friend list process. The player could be stuck in an endless retrieving friend list attempt. The player is never able to retrieve the friend list, and the loading screen keeps reappearing.
  • The game shows empty friend list.
...
auto ABSubsystem = IOnlineSubsystem::Get(ACCELBYTE_SUBSYSTEM);
auto FriendsInterface = ABSubsystem->GetFriendsInterface();
int32 LocalUserNum = 0;

FriendsInterface->ReadFriendsList(
LocalUserNum,
TEXT(""),
FOnReadFriendsListComplete::CreateWeakLambda(this, [](int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& Error)
{
if (bWasSuccessful)
{
// Do something when the query friend list is successful.
}
else
{
// Implement a solution to handle failed request.
}
}
));
...

Currently, if a retreiving friend list fails, the AGS OSS does not provide details about whether the failure was caused by an HTTP timeout or another issue. When the friend list is updated, it caches in the Unreal Engine AGS OSS. Following code is to get the AGS OSS' friend list cache:

...
auto ABSubsystem = IOnlineSubsystem::Get(ACCELBYTE_SUBSYSTEM);
auto FriendsInterface = ABSubsystem->GetFriendsInterface();

TArray<TSharedRef<FOnlineFriend>> NewCachedFriendList{};
FriendsInterface->GetFriendsList(LocalUserNum, TEXT(""), NewCachedFriendList);
...