[Resolved] Access Server Externally

edited January 2011 in Photon Server
Hello Everyone,

I am currently about two-three months in with game development with Unity3D, and Photon looks like it is my best server option. I've taken a break from coding the actual game in order to implement the Networking factors.

I've become very comfortable with MySQL for the database, and I've slowly but surely been learning the ins-and-outs to Photon. I've reconstructed the Lite Demo scripts for the Unity3D client package multiple times, and I'm finally understanding some key concepts like Events, etc. I think I'm on the right track, but I wanted to consult the forums for some things that I'm stuck on.

Sorry about the off-topic above, I'm probably going to be on these forums a lot, and wanted to give a fair introduction. :)

My first question is probably really easy: How do I host the server on the Internet? I've done a lot of research on it, and I must be missing *something*.

Just for a connection test between two computers (one hosting the server, and one remote), I'm trying it with the simple Unity3D Realtime Demo (with the chess board and cubes).

Here is what I've tried so far: (My IPs refer to the server hosting IPs)

Changed the UDP IP Address in the XML file to both my Internal IP ( and my external (from http://www.whatsmyip.org/ ), but came to the conclusion that the default would work the best.

For the Game.cs script, I changed the ipPort variable to my external IP:5055.

I've setup a Static IP on both Windows XP (through Local Area Connection Properties), and through my Linksys Router (

I've Port Forwarded 5055 in the Linksys Port Forwarding section, the columns look like this: Application: Photon; Start: 5055; End: 5055; Protocol: UDP; IP Address:; Enable: Checked.

I checked with two different UDP port check programs that the Port 5055 is open under UDP when Photon is not running, and blocked when it is running.

I've tried enabling DMZ and unchecking "Block Anonymous Internet Requests" under the Firewall in the Linksys Settings. (Re-enabled when they didn't work...)

I can run multiple instances of the Game and communicate between them locally, with no problems.

I might be forgetting something I tried...

Anyway, what could the problem be? Is there something that I haven't tried yet?

This isn't that much of a problem at this stage of production, but I might as well get it out of the way now.



  • Boris
    Hi jnmwizkid (how do you pronounce that? ;)),

    this is how it should work:

    1) start your server with IP - this value means that photon listens to all available IPs of the computer. Do NOT enter the external IP - the host doesn't know about it so it won't work.
    2) make sure no firewall is blocking the port that you are connecting to
    3) Enable Port-forwarding on your router for the ports that your client uses, unless you configured it differently port 5055 for UDP, port 4530 for TCP, and if you use flash or silverlight port 843 and 943 TCP.
    4) Use the external IP (http://www.whatsmyip.org) in your game client.

    That's it.

    One more thing: Sometimes you have two routers behind each other, that makes it a little bit more complicated. The first router (seen from the internet) has to forward the port to the second router, and this router then has to forward the same port to the machine with photon.

    Forget about DMZ etc - port forwarding is all you need.

    There are also some web sites that you can use to test if your port is really open, google for port scan or port probe.
  • dreamora
    3) this also applies if you use unity 3 webplayer
  • Alright, made some progress. Not really, the remote computer still can't connect, but...

    I used CMD's "netsh routing ip nat" portmap and addressmap functions to do some forwarding, still nothing. The port probe site: http://www.semios.se/portprobe/ports/index.php

    lists Port 4530 TCP open when photon runs, and closed when it is not running.
    Port 5055 UDP is always "Hidden."

    When the remote computer tries to connect via TCP (tried this method since the port appeared to be open on the port probe site), the Unity Output Log on the remote computer returns the following:
    Connect() failed: System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions.
      at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) [0x00000] in <filename unknown>:0 
      at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0 
      at System.Net.Sockets.Socket.Connect (System.Net.IPAddress address, Int32 port) [0x00000] in <filename unknown>:0 
      at ExitGames.Client.Photon.TConnect.StartConnection () [0x00000] in <filename unknown>:0 
    UnityEngine.Debug:Internal_Log(Int32, String, Object)
    ExitGames.RealtimeDemo.Game:DebugReturn(DebugLevel, String)
    ExitGames.Client.Photon.TPeer:Connect(String, String)
    ExitGames.Client.Photon.PhotonPeer:Connect(String, String)

    What does this mean, exactly? What does this show that I may have setup wrong?

    And Boris, it's like, "J-N-M-whiz-kid" :P

  • Boris
    I assume this is the Unity web player?
    open port 843 TCP, it needs to connect to the policy app first.
  • Oh, sorry, I meant to say this earlier. No, it is a Windows Standalone.
  • Boris
    mh.. did you try run it as admin?
  • Woah, I just found something by accident. I was using the Port Probe mentioned earlier, and I happened to look at the PhotonSocketServer log. Whenever I Port Probe 4530 TCP, the Log returns this message:
    248: 16:19:06.287 - CTCPSocketServer::ReadCompleted - Exception - CTCPStreamProcessor::ProcessDataStream() - Invalid message format, expected first byte to be 0xF0 OR 0xFC. Got: 5c - 5C 6E 5C 6E  - \n\n

    I understand that the message format error is probably because it is coming from the port website, but this shows that my computer IS receiving messages from the internet, but only on TCP. The log returns nothing with UDP on 5055.

    Looking back on the log from when the remote game instance was trying to connect, there is no record, however.
  • Boris wrote:
    mh.. did you try run it as admin?

    I have full administrative rights on my PC, if that is what you're talking about?
  • Boris
    well, on win7 / vista there is still the option to "run as administrator" using right click
  • Alright. Unfortunately, it seems the problem was not with the server computer. When I tested the server with someone else on a different remote computer, it worked flawlessly. It still does not work with the original remote computer, and I'm not sure why.. any suggestions?

    Also, for PROM or anyone else that may be experiencing these issues, two things you can try:

    On XP:

    Under Network Connections, go to the properties under Internet Gateway.
    Then click Settings.
    For each port you want to open, press Add. For description, use anything. For IP Address, use your local IP that the server is running on (192.168.x.x). External Port and Internal Port are the same (5055 with UDP, 4530 for TCP).

    Also, I'm not sure if this would have any effect, and I actually have it disabled now, as it doesn't seem needed, but:

    On XP, go to CMD:
    netsh, enter
    routing, enter
    ip, enter
    nat, enter

    type "install", then

    Use the "help" function on different functions for an explanation, but "add interface", then "add portmapping", is like a manual portforwarding, it seems. I'm not entirely sure about this, but might as well contribute.

    Alright, thanks.
  • It seems that we have isolated the issue. The problem was caused by "Windows Live OneCare Firewall" running in the background on the remote computer (not the server computer).

    It's a shame that we went through all this trouble over something so simple... >.<
  • dreamora
    I fear when it comes to networking, this kind of "simple problem" will be what you most commonly waste time with :)
    thats why MMOs are often done with TCP, removes a lot of the problems, if you put the firewall configs for mcafee and norton onto the page so lemmings with 0 pc knowledge can connect you, you are normally fine ;)
  • JNM, did you get past this?
  • Yes, digoxy. It was not a problem with the server computer at all, it was simply an overlook on the remote computer's firewall. I posted some tricks above if you're still having trouble.