Author Topic: ServerList.Entry.internalAdress = 255.255.255.255 when not from unity editor  (Read 4298 times)

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
hi!
yes, its me again.

im creating an udp lobbyserver without problem.

then run a unity program and creates a server with:

  1.                                 TNServerInstance.serverName = "Test Server";
  2.                                 TNServerInstance.Start(5127, 5128, null, TNServerInstance.Type.Udp, Tools.ResolveEndPoint("mytest.com:5129"));
  3.  
  4.  

it works fine from the unity editor, if i print the content from the serverlist i can see the external address being: 190.205.something.something:5127
and the internal adderss being 192.168.0.2:5127


but!
if i build the program and run the .exe file, when i print the serverlits, i can see the external address being: 190.205.something.something:5127 correctly
but the internal address becomes 255.255.255.255:5127

after that i got "The requested address is not valid in its context" messages


what im doing wrong?



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Internal address being 255.255.255.255? That's odd. If you run TNServer.exe (server executable), what do you see listed under IP addresses?

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
it says this:

  1. Local IPs: 1
  2.   1: 192.168.1.103 (Primary)
  3.  
  4. Gateway:  None found
  5.  

i am behind a wireless router, and i understand the nat table could be a problem.

the thing is, the nat routing is working fine when i run the program from the unity editor.
it only fails when its run standalone.

does the unity editor has an special permission?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
You generally give permissions (in Windows) the first time you run the application. That's when the "allow access" dialog shows up. You can get it to show up again by simply renaming the executable. When you run it, you get a dialog that asks if you want to give this app permission to access LAN and Internet, as two different checkboxes. Both must be checked. The first time you execute it, it won't take hold. You must close the app and run it the second time for your permission changes to take effect.

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
i did it, but still 255.255.255.255   :'(

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Curious. I've never seen that. I've even just created a simple app with the following script attached to a game object:
  1. using UnityEngine;
  2. using TNet;
  3. using System.Threading;
  4.  
  5. public class ShowIP : MonoBehaviour
  6. {
  7.         string text = "";
  8.         Thread mThread;
  9.  
  10.         void Start ()
  11.         {
  12.                 text = "LAN: " + Tools.localAddress;
  13.                 mThread = new Thread(ResolveWAN);
  14.                 mThread.Start();
  15.         }
  16.  
  17.         void OnDestroy () { if (mThread != null) mThread.Abort(); }
  18.         void ResolveWAN () { text += "\nWAN: " + Tools.externalAddress; mThread = null; }
  19.         void OnGUI () { GUILayout.Label(text); }
  20. }
Built it for Stand-alone on Windows 8.1, the expected IPs show up.

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
nope, still dont work

here is what the server console shows:

  1. TCP Lobby Server started on port 5129
  2. Press 'q' followed by ENTER when you want to quit.
  3.  
  4. UPnP discovery failed. TNet won't be able to open ports automatically.
  5. 190.205.114.6:61551 added a server (192.168.1.103:5127, 190.205.114.6:5127)
  6. 190.205.114.6:61551 has disconnected
  7. 190.205.114.6:61573 added a server (255.255.255.255:5127, 190.205.114.6:5127)

the first one was run from the unity editor.

then built the application, an run the .exe, and... you can see  the 255s...

this makes no sense!!

are you behind a router too?

i really doubt that there is a special communication between unity and my router :S

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Yes I am behind a router, but local address is retrieved from your system, not the router. Did you give that script I pasted a try?

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
your script works fine.

both, unity editor and standalone...

so.... why is the server creating not working? :(

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
ok...

my bad!

its not the external address the one that is not being passed.

its the internal!!! (192.168.x.x)

sorry for the confusion.

is there a way to pass it???

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
well... i made it "work"...

your script gave a idea...
the "thread" part to be more specific.

i said to myself "may be, the library hasnt had time to resolve the ip"

so i changed to code to this:

  1.                                 Debug.Log(Tools.localAddress);
  2.                                 TNServerInstance.serverName = "test Server";
  3.                                 TNServerInstance.Start(5127, 5128, null, TNServerInstance.Type.Udp, Tools.ResolveEndPoint("mytest.com:5129"));
  4.  


note that i only added  the debug.log line.

and now it works!!!

so, may be there is some kind of delay?

or may be the library doesnt check the local address before starting a remote lobby???



thanks!!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
The external address is sent to the lobby alongside the "add server" packet.
  1.         /// <summary>
  2.         /// Add a new entry to the list of known servers. Used by the Lobby Server.
  3.         /// ushort: Game ID.
  4.         /// string: Server name.
  5.         /// ushort: Number of connected players.
  6.         /// IPEndPoint: Internal address
  7.         /// IPEndPoint: External address
  8.         /// </summary>
  9.  
  10.         RequestAddServer,
The external address is cached on line 78 of TNTcpLobbyLink.cs and line 90 of TNUdpLobbyLink. In both cases they go through TNTools.externalAddress, which calls GetExternalAddress(), which takes a while to complete. Current public version of TNet uses dyndns for this, which is quite slow as it turns out, so I've replaced it with a variety of other sites. Pro version of TNet (1.9.6) is much faster at retrieving the external IP. Perhaps the address retrieval was simply failing on your end and the new faster method will work as expected.