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. Dismiss Notice

Third Party SOLVED: Weird PUN2 issue - Connecting To Photon Network

Discussion in 'Multiplayer' started by kamicompute, Feb 23, 2020.

  1. kamicompute

    kamicompute

    Joined:
    Jun 5, 2019
    Posts:
    8
    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:

    Code (CSharp):
    1.  
    2. using Photon.Pun;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6.  
    7. public class NetworkController : MonoBehaviourPunCallbacks
    8. {
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.  
    13.         Debug.Log("Connecting to Photon Network");
    14.         PhotonNetwork.ConnectUsingSettings(); //2
    15.  
    16.     }
    17.  
    18.     public override void OnConnectedToMaster()
    19.     {
    20.         Debug.Log("We're now connected to the " + PhotonNetwork.CloudRegion + " server!");
    21.     }
    22. }
    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:
    https://forum.photonengine.com/discussion/15531/photon-hangs-on-connectingtonameserver#latest

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

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,016
    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.
     
    kamicompute likes this.
  3. kamicompute

    kamicompute

    Joined:
    Jun 5, 2019
    Posts:
    8
    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.
     
    omr02 and nicotina04 like this.
  4. nicotina04

    nicotina04

    Joined:
    Oct 29, 2021
    Posts:
    1
    kamicompute hey you saved our team project thanks a lot!