PhotonVoiceNetwork try to connect in an endless loop

When using the command PhotonVoiceNetwork.ConnectAndJoinRoom (AutoConnectAndJoin and AutoLeaveAndDisconnect = false), and the connection could not be established (e.g. a room could not be joined, created), PhotonVoiceNetwork try to connect again, and again and...
This is due to the ConnectOrJoin function, as if it has the PeerCreated or Disconnected state, it call’s connect again.

Can you please add a value which gives a max try-connection-count, so after calling X times this command which was triggered either by manually calling PhotonVoiceNetwork.ConnectAndJoinRoom or by the autoJoin function it will stop.
If the max try connection amount is reached, PhotonVoiceNetwork will no longer try to connect until manually forced (ConnectAndJoinRoom), or after a new Pun connection was established (AutoConnectAndJoin).

This makes sense, because if there is a problem with the connection (maybe auth. issues, or the like), PhotonVoiceNetwork is endlessly trying to connect to the server, which is not what we want.

What do you think?


  • As an alternate we can simply enable/disable the PhotonVoiceNetwork MonoBehaviour, maybe that would be the workaround for that?!
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited January 2021
    Hi @AndreWe,

    Thank you for reporting this and for your suggestion!

    We already have a task in our backlog to better handle this.
    Max connect or join retries/attempts is one possible solution that we are considering yes.

    However the known causes for the endless loop differ from what you are reporting. Actually I don't really understand how to reproduce it in your case.
    Currently if you explicitly disconnect the Voice client manually it won't try to connect automatically.

    The other known causes for the FollowPun endless loop are:

    - PUN joins a room in offline mode, PUN client state is Joined, PhotonVoiceNetwork.Instance.AutoConnectAndJoin = true, so Photon Voice will try to follow PUN endlessly when there is no internet connection.
    - PUN client can connect but Photon Voice client can't somehow.
    - Photon Voice client cannot join the voice room 'mirroring' the PUN room.
  • We have an own authentication code for PUN and for Voice. We are testing a case where the authentication fails, in that case, PUN Voice will always start to reconnect. But that is a case we want to avoid. If you like, we can prepare a small repo for your, which shows the case. Would that help?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @AndreWe,

    Well how about a minimal repro script on hatebin or hastebin or pastebin or gist?
    I believe it should be a simple one class for doing auth/connect right?