question

Chris Gaudino avatar image
Chris Gaudino asked

PlayFab Party Unity on iOS fails to connect after app is backgrounded and resumed

We are using the PlayFab Party SDK for Unity (SDK version 1.5.0.2-main.0, Unity version 2019.4.3). In our iOS builds, the first connection after freshly opening the app works fine. However, once the app has been backgrounded or the device locked for a few seconds, all subsequent connection attempts fail until the app is force closed and restarted. We've observed this behavior both in our own game scenes as well as the example scene provided in the SDK.

When resuming the app, the following messages are logged:

dnssd_clientstub write_all(15) DEFUNCT

failed to establish or maintain a connection to a network or remote peer

All subsequent connection attempts have the same result until the app is force quit and restarted.

To reproduce:

1. Build the PlayFab Party Unity example scene for iOS.

2. Open the app and press "Connect and Join Network". The connection will succeed.

3. Force close the app.

4. Open the app again. Lock the device and wait 5-10 seconds.

5. Unlock the device and press "Connect and Join Network" again. It will now fail.

We have tried destroying and recreating the local player/endpoint, as well as cleaning up the PlayFabPartyManager and reinitializing it when the app resumes, but the result is the same.

sdksmultiplayer
17 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Citrus Yan avatar image Citrus Yan commented ·

Mostly like there was no internet connection when the app had been backgrounded or the device locked, therefore the error "failed to establish or maintain a connection to a network or remote peer" would occur.

May I know how did you "destroying and recreating the local player/endpoint, as well as cleaning up the PlayFabPartyManager and reinitializing it when the app resumes" ? Could you share the code snippet of how you did that?

0 Likes 0 ·
Chris Gaudino avatar image Chris Gaudino Citrus Yan commented ·

The errors do not occur until the device is unlocked and the application resumes, and they reoccur on every subsequent connection until the app is completely restarted. This occurs on both WiFi and cellular data and is 100% reproducible for us. If the cause is a momentary loss in internet connection, then the issue is that the Party SDK is unable to recover when the connection returns.

We added a function to PlayFabMultiplayerManager to try to reset its state. We've tried a lot of variants of it, but in general they look something like this:

public void ResetState()
{
    SDK.PartyDestroyLocalUser(_partyHandle, _localUserHandle, null);
    SDK.PartyNetworkDestroyEndpoint(_networkHandle, _localEndPointHandle, null);
    SDK.PartyNetworkLeaveNetwork(_networkHandle, null);


    _networkHandle = default;
    _localEndPointHandle = default;
    _localUserHandle = default;


    _playFabMultiplayerManagerState = _InternalPlayFabMultiplayerManagerState.Initialized;
}

We have also tried to completely cleaning up and reinitializing the manager:

public void ResetState()
{
    CleanUp();
    _Initialize();
}

We've since removed these functions since the result is the same with or without them.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Chris Gaudino commented ·

What I did was to call the following method to change the state to Initialized:

PlayFabMultiplayerManager.Get()._SetPlayFabMultiplayerManagerInternalState(PlayFabMultiplayerManager._InternalPlayFabMultiplayerManagerState.Initialized);

After this, I can create and connect to a network.

0 Likes 0 ·
Show more comments
Chris Gaudino avatar image Chris Gaudino Citrus Yan commented ·

This issue still occurs after upgrading to the new version of the PlayFab Party Unity SDK released today (1.5.0.3-main.0).

0 Likes 0 ·
Jon Liu avatar image Jon Liu Chris Gaudino commented ·

Did you ever solve this issue? Would love to hear how.

0 Likes 0 ·
Stu Wallinger avatar image Stu Wallinger commented ·

Did you manage to resolve this ? We're having the exact same issue.

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.