Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

Third Party New example of Photon PUN and WebGL

Discussion in 'Multiplayer' started by Mal_Duffin, Dec 5, 2020.

  1. Mal_Duffin

    Mal_Duffin

    Joined:
    Jan 22, 2015
    Posts:
    71
    We just released an alpha version of our game as a WebGL build. It can be played online, and we use Photon PUN for our multiplayer tech.

    Crooks Like Us by Out Of Tune Games (itch.io)

    Using WebGL is a great way to ensure that all of the players are using the same version.
     
    spark-man and Brodus like this.
  2. LorisToia

    LorisToia

    Joined:
    Jan 21, 2021
    Posts:
    14
    How to make Photon works in webgl build?
    my project works in editor and in windows build, but in webgl photon doesn't connect after waiting 2 mins he show an error:
    OperationResponse 230: ReturnCode: 32736 (No auth request during expected wait time)
     
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,021
    This sounds like a problem we solved recently.
    The exact cause is unknown to me but the general issue was this: The game tried to connect in some scene's script in the Start() callback. This is usually fine but here, Unity probably loaded some assets or started another, long task and the main thread was blocked long enough for the Name Server to discard the connection (on the Name Server, inactive connections are discarded faster than anywhere else).

    So the workaround/fix was to delay the call to connect.

    WebGL can be a bit tricky, if the single main thread is not available for a while.
     
    zoeyducoeur likes this.
  4. dhvanildudhagra123

    dhvanildudhagra123

    Joined:
    Jun 2, 2022
    Posts:
    1
    during development did you encounter any issue of background tab issue. currently i am having issue of photon disconnection if tab was in background for more that one minute. how did you solve this issue ?
    for disconnection cause i am getting ClientTimeout
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,021
    For a short time, you might get away with playing some audio in the background tab. It doesn't need to be audible to keep the JS processing and the connection up. I know this solution only as high-level idea, so I can't provide more details.

    As JS is likely not running while the tab is in the background, it often better to not keep the connection over long times. This way, the others notice you are not active. The client doesn't need to receive data it's not processing, etc.

    When creating rooms, you can set a PlayerTTL value. This is how long a player stays in a room, even without a connection. If the client becomes active again (tab in focus), you can do a ReconnectAndRejoin() attempt to get back into the same room as before.
     
    Brodus likes this.