Author Topic: [Help] Server crashing immediately on startup  (Read 4804 times)

andrewbr

  • Guest
[Help] Server crashing immediately on startup
« on: April 01, 2013, 09:15:43 PM »
Just downloaded the latest (1.6.6) version. Following this tutorial:  http://www.youtube.com/watch?v=cTjy-L8C6WM

After unzipping and attempting to run the TNServer.exe, the program crashes (Unresponsive, Windows begins looking for a solution). Running it directly from the command prompt gives me the following error:

Unhandled Exception: System.Net.Sockets.SocketException: Only one usage of each
socket address (protocol/network address/port) is normally permitted
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at TNet.UPnP.ThreadDiscover(Object obj)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart(Object obj)

I allowed access the first time the window popped up, but it still crashes immediately every time.  I assume (or hope) there is something I can do on my machine to add more ports/sockets or open availability, but I am in uncharted waters here and am at a loss. Was wondering if anyone could offer a suggestion.

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [Help] Server crashing immediately on startup
« Reply #1 on: April 01, 2013, 10:49:01 PM »
Did you run two instances of the server? The error is telling you that something is already listening to the port you are trying to listen to.

andrewbr

  • Guest
Re: [Help] Server crashing immediately on startup
« Reply #2 on: April 03, 2013, 05:54:50 PM »
Nope, only one instance. To double check, I rebooted completely and ran only this, still got the same issue.

andrewbr

  • Guest
Re: [Help] Server crashing immediately on startup
« Reply #3 on: April 03, 2013, 09:36:20 PM »
Did some more reading - after a netstat -ano look, none of the default ports are in use. Even changing the inputs to other available ports results in the same message. I'm wondering if there is some permissions thing I am missing. just tried with the latest version, with the same results.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [Help] Server crashing immediately on startup
« Reply #4 on: April 04, 2013, 04:43:59 AM »
If you run the server from within Visual Studio (or MonoDevelop) you should get more debugging information including a line on which it fails. It would be helpful. You can find the project file and the associated CS file inside the same ZIP where you got the server executable.

andrewbr

  • Guest
Re: [Help] Server crashing immediately on startup
« Reply #5 on: April 04, 2013, 11:56:10 PM »
Results become:


Unhandled Exception: System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted

   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)

   at System.Net.Sockets.Socket.Bind(EndPoint localEP)

   at TNet.UPnP.ThreadDiscover(Object obj) in c:\Users\Andrew\Documents\New Unity Project\Assets\TNet\Common\TNUPnP.cs:line 161

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

   at System.Threading.ThreadHelper.ThreadStart(Object obj)
The application exited with code: -532459699


line 161 is:

UdpClient receiver = new UdpClient(port);


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [Help] Server crashing immediately on startup
« Reply #6 on: April 05, 2013, 09:31:09 AM »
Yup, it suggests that the port cannot be listened to. Well, it shouldn't crash in any case. I'm going to move the "new UdpClient" part into the try/catch block below. It should look like this afterwards:

  1. UdpClient receiver = null;
  2.  
  3.                 try
  4.                 {
  5.                         receiver = new UdpClient(port);
  6.                         receiver.Client.ReceiveTimeout = 3000;
  7.  
  8.                         IPEndPoint sourceAddress = new IPEndPoint(IPAddress.Any, 0);
  9.  
  10.                         for (; ; )
  11.                         {
  12.                                 byte[] data = receiver.Receive(ref sourceAddress);
  13.  
  14.                                 if (ParseResponse(Encoding.ASCII.GetString(data, 0, data.Length)))
  15.                                 {
  16.                                         receiver.Close();
  17.  
  18.                                         lock (mThreads)
  19.                                         {
  20.                                                 mGatewayAddress = sourceAddress.Address;
  21.                                                 mStatus = Status.Success;
  22.                                                 mThreads.Remove(th);
  23.                                         }
  24.                                         return;
  25.                                 }
  26.                         }
  27.                 }
  28. #if DEBUG
  29.                 catch (System.Exception ex)
  30.                 {
  31. #if UNITY_EDITOR
  32.                         UnityEngine.Debug.LogWarning(ex.Message);
  33. #else
  34.                         Console.WriteLine("ERROR: (UPnP) " + ex.Message);
  35. #endif
  36.                 }
  37. #else
  38.                 catch (System.Exception) { }
  39. #endif
  40.                 if (receiver != null) receiver.Close();