Connection doesn't work in UWP build, but works in editor.

Options

I've been using this (simplified) script for a few months,

using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;
using Hashtable = ExitGames.Client.Photon.Hashtable;
using UnityEngine;

public class MenuConnectionController : MonoBehaviourPunCallbacks, IConnectionCallbacks
{
    public string gameVersion = "v0.0.1b";
    public int sceneIndex = 2;
    
    // Start is called before the first frame update
    void Start()
    {
        if (!PhotonNetwork.IsConnected)
        {
            Debug.Log("Not connected " + PhotonNetwork.NetworkClientState);
            playButton.interactable = false;
            PhotonNetwork.AutomaticallySyncScene = true;
            try
            {
                if (PhotonNetwork.ConnectUsingSettings())
                {
                    Debug.Log("Connection " + PhotonNetwork.NetworkClientState);
                }
                else
                {
                    Debug.Log("No Connection");
                }
            }
            catch (System.Exception e)
            {
                Debug.Log(e);
            }
            PhotonNetwork.GameVersion = gameVersion;
        }
        else {
            Debug.Log("Connected (1) " + PhotonNetwork.NetworkClientState);
            canPlay = true;
            playButton.interactable = true;
        }
    }

    public override void OnConnectedToMaster()
    {
        Debug.Log("Gawdam " + PhotonNetwork.NetworkClientState);
        canPlay = true;
        playButton.interactable = true;
        PhotonNetwork.LocalPlayer.NickName = PlayerDataController.instance.data.username;
    }
}


but when I switched my build to Universal Windows, OnConnectedToMaster() doesn't get called, and with full PUN logging my log file looks something like

Not Connected
{...}

IPhotonSocket.Connect() ns.photonengine.io:5058 this.Protocol: Udp
{...}

Connection ConnectingToNameServer
{...}

SendOutgoingCommands ignored socket is not connected. pid:65535
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String)
ExitGames.Client.Photon.EnetPeer:SendOutgoingCommands()
ExitGames.Client.Photon.PhotonPeer:SendOutgoingCommands()
Photon.Pun.PhotonHandler:LateUpdate()

SendOutgoingCommands ignored socket is not connected. pid:65535
{...}

SendOutgoingCommands ignored socket is not connected. pid:65535
{...}

With SendOutgoingCommands ignored socket is not connected. pid:65535 being repeated until the game is stopped. I've tried enabling all the UWP capabilites, reinstalling PUN, changing the dlls manually to use IL2CPP, but the furthest it gets in the build is ConnectingToNameServer. Everything works in the editor as it's supposed to.

Unity Version: 2022.2.0b1, but I can try it with 2023 alpha :)

Best Answer

  • Tobias
    Tobias admin
    edited September 2022 Answer ✓
    Options

    Which PUN version?

    We don't support beta Unity versions, by the way. Use a LTS version and you will avoid a lot of the issues you run into now.

Answers

  • Tobias
    Tobias admin
    edited September 2022 Answer ✓
    Options

    Which PUN version?

    We don't support beta Unity versions, by the way. Use a LTS version and you will avoid a lot of the issues you run into now.

  • I'm using the newest PUN version, but switching to Unity 2021 LTS made it work! Thank you Tobias, I never would have thought of trying a different Unity version.

  • Tobias
    Options

    Thanks for the update on this. Glad it helped!