SOLVED: Weird PUN2 issue - Connecting To Photon Network

Hello all,

Hope anyone can help me with this. I’m trying to set up PUN2, but in my existing project, it won’t connect.
I went as far as removing all plugins, packages, scripts, assets resources etc. until I ended up with an empty project, with the Connect to Photon script attached to my main camera. Here’s the code:

using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NetworkController : MonoBehaviourPunCallbacks
{
    // Start is called before the first frame update
    void Start()
    {

        Debug.Log("Connecting to Photon Network");
        PhotonNetwork.ConnectUsingSettings(); //2

    }

    public override void OnConnectedToMaster()
    {
        Debug.Log("We're now connected to the " + PhotonNetwork.CloudRegion + " server!");
    }
}

It never connects. When enabling full logging, this is the output in console:

Connecting to Photon Network
UnityEngine.Debug:Log(Object)

Connect()
UnityEngine.Debug:Log(Object)

SocketUdp, .Net, Unity.
UnityEngine.Debug:Log(Object)

IPhotonSocket.Connect() ns.exitgames.com:5058 this.Protocol: Udp
UnityEngine.Debug:Log(Object)

I cannot wrap my head around this issue. When I create a new project, and install PUN2 on the exact same way, and add the script above, it works directly; It connects to the region server.
I’ve went through any possible setting I could think of, up to the player settings and preferences, mimicking each setting. I’m stunned.

Does anyone know why this is happening? Is there a way to get more indepth debug logging to figure out why it refuses to connect?
I also made a thread on photonengine.com, but thusfar, no replies:
The Photon Forum is Closed Permanently. | Photon Engine

Hopefully someone is able to shed some light on this.
Many thanks in advance!

I replied in our forum.
This is a tricky case and you tried already everything one could come up with, so I guess nobody has a proper reply.
I had a few questions though and maybe you send the project to check here.

1 Like

I managed to find the issue.

In the empty project, I saw some ProjectSettings files lingering, so I did the following to narrow down the culprit:

  • copied & removed all files under ProjectSettings;
  • started project, configured / installed required assets;
  • after successful run, photon works;
  • replacing copied setting files one by one;
  • found photon breaks due to TimeManager.asset file settings;

I compared the TimeManager.asset from my ‘old, not working project’, and a test project in where photon works.

The content of the non-working file was:

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
— !u!5 &1
TimeManager:
m_ObjectHideFlags: 0
Fixed Timestep: 0.02
Maximum Allowed Timestep: 0.1
m_TimeScale: 0
Maximum Particle Timestep: 0.03

The content of the file that does allow Photon to connect:

y 2019.3.0f5 þÿÿÿ ÿÿÛâw–¦/ZX\ÇÔ‹èÞ Z 7 € ¦ €² € ¡ € ¡ € ¡ €4 ¡ €@ TimeManager Fixed Timestep Maximum Allowed Timestep m_TimeScale Maximum Particle Timestep ×£<«ªª> €?Âõ<

After I copied the working file to the non-working project, Photon could connect.

Hope this helps you in the development and other people that run into a similar issue.

Kind regards,
Kami.

4 Likes

kamicompute hey you saved our team project thanks a lot!