Author Topic: StartRemote function does not open ports.  (Read 1429 times)

junjet

  • Guest
StartRemote function does not open ports.
« on: November 27, 2013, 11:08:16 PM »
Hi Aren,

I was trying to create a game server locally & register it on a remote lobby server which means I have to use the following script:

--
TNServerInstance.Start(5127, udpPort, "server.dat", TNServerInstance.Type.Udp, Tools.ResolveEndPoint("ip", lobbyPort));
--

This will in turn fire the instance.StartRemote function instead of the default instance.StartLocal function.

I found out that unlike on instance.StartLocal where both tcp and upd ports are being opened, these ports were not being opened on instance.StartRemote.

---
mUp.OpenTCP(tcpPort);
mUp.OpenUDP(udpPort);
---

On instance.StartRemote the 2 lines above is missing so even though I will be able fetch the server info from the lobby server, I wont be able to connect because the ports are open.

The solution is to add these 2 lines inside the instance.StartRemote function like this: (which is exactly the same thing you did on instance.StartLocal)

--
      if (mGame.Start(tcpPort, udpPort))
      {
                // - added lines
         mUp.OpenTCP(tcpPort);
         mUp.OpenUDP(udpPort);
                // - added lines

         if (!string.IsNullOrEmpty(fileName)) mGame.LoadFrom(fileName);
         return true;
      }
--

Doing so fixed my issue, so I just want to know if what I did was right and that maybe it needs to be included in the official package?

Thanks,

Junjet

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: StartRemote function does not open ports.
« Reply #1 on: November 28, 2013, 01:37:04 AM »
Seems reasonable. I've done that on my end, thanks.