Stuck at connecting a peer... (using Unity)

Options
Cup
Cup
edited March 2014 in Photon Server
Hello,

I have been stumped on what I think should be one of the easiest parts of using Photon Server.

I'm sure I'm misinterpreting this, or there's some obvious oversight. This has been holding up my progress on making my game multiplayer for awhile, now. So here's the current problem:

I am using Photon Server with Unity. I have a class which I am using to connect to my server (running on my machine currently) that implements both IPhotonPeerListener and Photon's MonoBehaviour. Within it, I have the followed code to begin connecting to my local server (in the Awake() function):

[code2=csharp]peer = new PhotonPeer(this, ConnectionProtocol.Udp);
connected = false;
peer.Connect("localhost:5055", "TinyTactics");[/code2]

I've found that the "peer.Connect..." line always returns false. The documentation on this function says it should only return false if the hostname has an incorrect format. I have copied this format from the Photon Server docs, and looked at multiple other sources which all use the same syntax. As far as I understand, this should not be returning false, regardless of if my server is running or not. Thus, the connection is never initialized and the status code never changes.

I really don't understand what's happening. I have tried replacing localhost with 127.0.0.1, my local network IP, and my public IP. I've also tried omitting the port (I have ensured the port is also correct). My application name is also correct, I have double checked this and tried with different application names. So what is going on?! I can't run peer.Service() later on without error either, since this line is evaluating to false.

Please let me know what I'm missing, or if I need to take any further troubleshooting steps.

Thank you very much!

Comments

  • cuongvu
    Options
    You can try this way: Check Game Server IP Config on Photon Control and set it to correct IP as you use in code.
  • Cup
    Options
    cuongvu wrote:
    You can try this way: Check Game Server IP Config on Photon Control and set it to correct IP as you use in code.
    As I've said, I've tried using my local and global IP address, to no avail.
  • Tobias
    Options
    I'm sorry to reply late but when skimming through this topic, it seemed you got a reply.

    Your code looks like connected is never set by peer.Connect(). I hope you are aware of that.
    Please let me know which SDK (platform and version) you are using and how you test. Are you using a simulator or such?
  • Cup
    Options
    Tobias wrote:
    I'm sorry to reply late but when skimming through this topic, it seemed you got a reply.

    Your code looks like connected is never set by peer.Connect(). I hope you are aware of that.
    Please let me know which SDK (platform and version) you are using and how you test. Are you using a simulator or such?

    No problem, thanks for getting back to me.

    I am using the Unity Client SDK, newest version (3.2.2.1) and the Photon Server SDK on my Windows 7 machine (newest version as well, 3.4). No simulation/emulation, I've been running the Unity client on the same Windows machine that I'm running the Photon Server on.

    I am aware that connected isn't set by peer.Connect(). I actually set it later on with this block of code: (in addition to peer.Service() in my Update() function)

    [code2=csharp]public void OnStatusChanged(StatusCode statusCode)
    {
    if (statusCode == StatusCode.Connect)
    {
    this.connected = true;
    }
    }[/code2]

    The problem is, if I write Debug.Log(peer.Connect( ... )) it always returns false, and consequently it never even tries to connect and OnStatusChanged is never called.
  • Tobias
    Options
    I can't reproduce the issue on my machine, no matter where and how I try it.
    I used the same SDK's code as basis and for me Connect() returns true. Even if I don't even run Photon.
    Maybe you have some config issue or something like a firewall will disallow even the host name resolution.

    You could try and set peer.DebugOut = DebugLevel.ALL; when you created it and see if some details pop up. You will have to call peer.Service() regularly and implement DebugReturn appropriately.

    You can't set the connected state. It won't change anything.
  • Cup
    Options
    My apologies, I've made a dumb error. I left the files from Photon Unity Networking in my client Unity project, which messed up the connect behavior.

    Thank you for your help, Tobias, it's been resolved.