How to fix "Operation FindFriends (222) not called because client is not connected or..." in Photon

Options

So here I am trying to add a Player as a friend to myself. I am following a tutorial for the same

So I am using the PlayFab to update the friend List. When the update is successful onFriendListSuccess() function is executed as given below.

 private void onFriendListSuccess(GetFriendsListResult result)
   {
    friends = result.Friends;
    onFriendListUpdated?.Invoke(result.Friends);
   }

In the above function as seen onFriendListUpdated event is invoked.In the listener basically this is the code:

 private void HandleFriendsUpdated(List<PlayFabFriendInfo> friends)
  {
    if (friends.Count !=0)
    {
      string[] friendDisplayNames = friends.Select(f => f.TitleDisplayName).ToArray();
      PhotonNetwork.FindFriends(friendDisplayNames)//-------------PROBLEM------------------
    }
    else
     {
      List<PhotonFriendInfo> friendList = new List<PhotonFriendInfo>();
      onDisplayFriends?.Invoke(friendList);
     }
  }


But I am getting the following error as given here:

Operation FindFriends (222) not called because client is not connected or not ready yet, client state: PeerCreated

UnityEngine.Debug:LogError (object)

Photon.Realtime.LoadBalancingClient:DebugReturn (ExitGames.Client.Photon.DebugLevel,string) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2564)

Photon.Realtime.LoadBalancingClient:CheckIfOpCanBeSent (byte,Photon.Realtime.ServerConnection,string) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2493)

Photon.Realtime.LoadBalancingClient:OpFindFriends (string[],Photon.Realtime.FindFriendsOptions) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1446)

Photon.Pun.PhotonNetwork:FindFriends (string[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2189)

PhotonFriendController:HandleFriendsUpdated (System.Collections.Generic.List`1<PlayFab.ClientModels.FriendInfo>) (at Assets/Scripts/MultiPlayer/PhotonFriendController.cs:33)

PlayFabFriendController:onFriendListSuccess (PlayFab.ClientModels.GetFriendsListResult) (at Assets/Scripts/MultiPlayer/PlayFabFriendController.cs:62)

PlayFab.Internal.PlayFabHttp/<>c__DisplayClass23_0`1<PlayFab.ClientModels.GetFriendsListResult>:<_MakeApiCall>b__1 () (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabHTTP.cs:215)

PlayFab.Internal.PlayFabUnityHttp:OnResponse (string,PlayFab.Internal.CallRequestContainer) (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:205)

PlayFab.Internal.PlayFabUnityHttp/<Post>d__12:MoveNext () (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:157)

UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

How do you fix this error?

Also the Screenshot is attached here:


Answers