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

  • Jakeco19
    Jakeco19
    edited August 2018
    //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.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited August 2018
    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)
  • Jakeco19
    Jakeco19
    edited August 2018
    Hi @JohnTube

    The Callbacks are never called and yes im using .Net 3.5;
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited August 2018
    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.
  • JohnTube
    JohnTube ✭✭✭✭✭
    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);
    	}
  • Hey all, I ran into the same problem yesterday and here's what I tried in order to fix it:
    I tried to restart Unity - Didn't solve the issue
    I tried to restart my PC - Didn't solve the issue
    I tried to move my Unity project - Didn't solve the issue
    I tried to clean my windows temporary files - Didn't solve the issue
    I tried to use the proposed by @mauri_up - Didn't solve the issue

    The actual solution for me was to find the PhotonServerSettings asset in my Unity assets folder and click "Clear RPCs" then "Refresh RPCs" then I clicked the "Reset" button under Best Region Preference

    That solved it in my case, hope this helps someone out there!
  • Hi, I also ran into this problem. (Photon v2)

    I tried all the steps stated above, and setting the region whitelist was the fix for me.

    Once I set a region I was able to connect to the editor again.

    Hope that helps.
  • Was facing this issue second time, last time had to revert by Collab few hours work, it was baaad, this time, Terralux Solution Worked for me! Problem was: standalones were going without problem, but unity editor wouldnt connect at all, it was debbuging it it connecting to master server, and could create room and play, but nooone seen him and he didnt see anyone. Bad situation. Luckily reseting RPC and Clearing and Refreshing RPCs in PhotonServerSettings helped!
  • I was having the same issue, the build versions were connecting on same room successfully, but editor couldn't join. Trying everything above couldn't fix it.
    Finally with some debug information I found out thet editor and build versions were connecting to servers from different regions.
    Fixing the region setting on photon server settings fixed it for me...
  • jackmca
    jackmca
    edited August 2022

    I encountered this problem after I pressed 'Clear RPCs' and then 'Refresh RPCs' in the PhotonServerSettings, I fixed this by pressing 'Reset' in the Dev Region.

  • I tried all of your suggestions and none of them worked can someone help me?