Author Topic: ServerList.Entry.externalAddress is not always external address  (Read 3360 times)

destructicorn

  • Guest
I'm using a lobby server much like the TNet example one.  I am having a problem where sometimes the ServerList.Entry.externalAddress is the internal address of the host machine.  Is there something I can do to fix this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ServerList.Entry.externalAddress is not always external address
« Reply #1 on: August 30, 2013, 01:22:50 PM »
It happens when TNet can't figure out the address. TNet figures it out by contacting a remote site that then returns the IP address in the HTTP page. TNet has a default link that won't work in the web player. You can host it on your own server (which is what I did in TNet). I've posted the PHP script in the past:
  1. <?php
  2. echo 'Current IP Address: ' . $_SERVER['REMOTE_ADDR'];
  3. ?>

pyscho2day

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 74
    • View Profile
Re: ServerList.Entry.externalAddress is not always external address
« Reply #2 on: September 02, 2013, 05:06:31 PM »
Aren,

I am also having this issue now.  I set up a page to return the external IP and if i browse to the page its always correct, but when going through the code it is returning a null value almost all of the time.  I am using 1.8.0. This would happen in prior versions but no where near as often, now I can't get the correct address to register.

The method I am watching is TNTools.GetResponse. When it tries to connect (WebResponse webResponse = request.GetResponse();) and get the information it is returning null.  I am using VS 2012 and UnityVS to debug. Could this be causing the issue for some odd reason?

The same method is woring fine when it pings the router to get the gateway information, but not when its trying to get the external address.  I have tried with the default url you have ("http://checkip.dyndns.org") and with mine and am getting the same results with both.  Could there just be something stupid that I am overlooking?

Regards

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ServerList.Entry.externalAddress is not always external address
« Reply #3 on: September 02, 2013, 05:32:44 PM »
Did you set up the policy server? If you're using a web player platform, it won't work unless you have a policy server running. It's a Unity limitation.

pyscho2day

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 74
    • View Profile
Re: ServerList.Entry.externalAddress is not always external address
« Reply #4 on: September 02, 2013, 05:42:24 PM »
Not using the web player. We are using standalone and up un-till i updated it would work 80% of the time. now it is resolving the ip less then 5% of the time.  I am finding that there is very little error checking in the code which is fine, and when/if my company purchases the Pro license will contribute any error checking we add to the repository as it will benefit the many.  But something this basic should work every time. I will look into a policy server but i don't think that is the answer as from what i have seen your just using basic .net 2.0 web calls to get the IP.  I have a sneaky suspicion that it is the format of the IP that is being retrieved from the page that is causing the issue.

I will look into the policy server but if you could please look into this as well it would be appreciated.

Regards

Edit:

I have started TNServer.exe (1.8) locally 20 times and only once did it return my external IP.
I did the same with TNServer.exe (1.7.3) and 10 out of 20 times it resolved the external IP.
« Last Edit: September 02, 2013, 06:04:01 PM by pyscho2day »

pyscho2day

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 74
    • View Profile
Re: ServerList.Entry.externalAddress is not always external address
« Reply #5 on: September 02, 2013, 11:09:20 PM »
Well it looks like UnityVS does not play well with TNET and possibly other network solutions as it connect to Unity via a port and is causing issues with connecting to the remote lobby server.  Bummer deal.

pyscho2day

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 74
    • View Profile
Re: ServerList.Entry.externalAddress is not always external address
« Reply #6 on: September 03, 2013, 10:29:00 AM »
After i made that last post i thought about it some more. I think the UnityVS is only part of the issue as i was having the problem when i was not trying to debug and the standalone server was also having issues.  I will play around with it some more and see what i come up with.

pyscho2day

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 74
    • View Profile
Re: ServerList.Entry.externalAddress is not always external address
« Reply #7 on: September 05, 2013, 05:24:24 PM »
just to update, replacing my now dead modem resolved the issue of not getting the external ip.  UnityVS still causes some problems though. but a small app that just launches a small app gets the ip logs it and shuts down, waits a few minutes and does it again and i haven't had one failure since replacing the modem.