Connecting to Master Server works in build but not editor.

Iv experience this issue several time once in unity 2018.1 and 2018.2.

the editor will work for a period of time then after maybe 2 - 3 hours working, it no longer connects to the master.

I then build the game and the built version works and is able to connect. any ideas or suggestions would be greatly appreciated.

Have tried.
- Fresh install
- Host
- New Project
- Different Versions of unity
- restarting router/Modem
- Restarting pc
- Restarting Unity

Comments

  • Jakeco19Jakeco19
    edited August 8
    //Connect To the master Server
        public void connectToPhoton()
        {
            PhotonNetwork.ConnectUsingSettings(versionName);
            currentNetworkStatus = "Connecting";
            Debug.Log("Connecting To photon.....");
        }
    
        //Was able to connect to the master Server
        private void OnConnectedToMaster()
        {
            PhotonNetwork.JoinLobby(TypedLobby.Default);
            currentNetworkStatus = "Connected";
            Debug.Log("Connected To the master");
        }
    
        //Was Disconnected from the master server
        private void OnDisconnectedFromPhoton()
        {
            currentNetworkStatus = "Disconnected";
            Debug.Log("Disconnected from Photon services");
        }
    
        public void joinRoomScene()
        {
            PhotonNetwork.LoadLevel("PlayScene");
        }
    
        //Joined lobby
        private void OnJoinedLobby()
        {
            Debug.Log("Joined Lobby");
        }

    This currently how I connect to the master.
  • JohnTubeJohnTube mod
    edited August 8
    Hi @Jakeco19,

    Thank you for choosing Photon!

    What "Scripting Runtime Version" are you using? (Edit -> Project Settings -> Player) under "Configuration"
    It should be "Stable (.NET 3.5 Equivalent)".
    PUN does not support 4.6 yet (see this forum post).

    If you implement these two callbacks which one is triggered and what disconnect cause do you get?
    void OnConnectionFail(DisconnectCause cause)
    
    void OnFailedToConnectToPhoton(DisconnectCause cause)
  • Jakeco19Jakeco19
    edited August 8
    Hi @JohnTube

    The Callbacks are never called and yes im using .Net 3.5;
  • JohnTubeJohnTube mod
    edited August 8
    This is tricky to reproduce.
    I think it may be a Unity bug.

    it no longer connects to the master.
    Could you explain this further?
    What happens? Any logs?
  • there is no real way to tell whats going on, other than the basic UI and Debugging that I have done.

    im not to sure how to explain it but it was working at one stage, then stopped working without any edits done to the game.

    using the Demos given, it gets stuck on connecting to name server, and will not proceed past that, but when I build the game it works perfectly fine.
  • Really need a solution this as it makes it impossible to even use Photon. seeing as i cant use the editor.
  • the editor will work for a period of time then after maybe 2 - 3 hours working, it no longer connects to the master.


    Just to make sure I understood this correctly: neither restarting the Unity Editor nor the PC solves the issue?
  • @Christian_Simon Hi,

    yes, you are correct. neither of those worked.
  • Odd, never heard of something similar before.

    How do you try to connect to Photon? Do you use Best Region feature or a certain Cloud Region? Which Connection Protocol do you use? If this occurs next time, please try to change at least one of the settings and see what happens afterwards.

    When you are already taking a look at the PhotonServerSettings, you can also try to set Pun Logging to Full and Network Logging to ALL and see, if this might give you any further hint about the problem.
  • iv tried all the options for trying to connect, none have worked. Have tried both UDP and TCP.

    have tried but once again never gets an error sent instead just sits on connecting to name server.
  • Fixed the Issue, simply the fix is if you're using auto Sync on a folder that contains your project files turn that off or move the project files and it fixes it.
  • Hi @Jakeco19,

    Thank you for the heads up.
    I'm glad you finally solved this mystery.

    I'm however not sure how to suggest the fix to other customers who might have the same issue.
    Could you please elaborate and share more details.
    That would be very much appreciated.
  • @JohnTube

    Here is how it was happening,

    I had the folder of my unity project in my OneDrive folder, which auto-syncs. This would be any case for google drive, megasync, Dropbox and pretty much any service that has a folder on your computer that syncs to the cloud.

    I moved that to local storage folder, say the desktop or C drive, and that fixed the issue.

    The best fix that i could say is to move the folder to somewhere that doesn't auto sync to a cloud service.
  • @JohnTube So Any Solution to this?
  • @Jakeco19 Which folder?
  • For anyone who comes across this issue, I managed to fix it after looking around the PhotonServerSettings file.
    I noticed the current region would be set during offline mode but didn't get reset when calling PhotonNetwork.Connect() in online mode.
    Try calling PhotonNetwork.Disconnect if you're switching from offline to online mode:
    if (PhotonNetwork.offlineMode)
    {
    PhotonNetwork.Disconnect ();
    }
    PhotonNetwork.offlineMode = false;
    PhotonNetwork.ConnectUsingSettings ("game version");
  • for new comers facing this, shoud try @mauri_up solution, other than that clearing unity temp folder from windows temp folder and clearing RPC"s from PhotonSettings and restricting reigon might help.
  • Hi im facing the same problem i following some tutorials and cant joined a room because the OnJoinedToMaster() callback doest work.
    	public void ConnectToPhoton()
    	{
    		PhotonNetwork.ConnectUsingSettings();
    		
    		Debug.Log("Connecting to photon...");
    	}
    
    	private void OnConnectedToMaster()
    	{
    		PhotonNetwork.JoinLobby(TypedLobby.Default);
    		
    		Debug.Log("We are connecte to master");
    	}
    
    	private void OnJoinedLobby()
    	{
    		string notification = "On Joined Lobby";
    		
    		connectPanel.SetActive(false);
    
    		statusText.text = notification;
    		statusText.color = Color.green;
    
    		Debug.Log(notification);
    	}
    
    	private void OnDisconnectedFromPhoton()
    	{
    		string notification = "Disconnected from photon services";
    
    		if(connectPanel.activeSelf)
    			connectPanel.SetActive(false);
    
    		statusText.tag = notification;
    		statusText.color = Color.red;
    		
    
    		Debug.Log(notification);
    	}
Sign In or Register to comment.