Author Topic: Unity hangs when TNet server is stopped  (Read 9755 times)

masterhyjinx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Unity hangs when TNet server is stopped
« on: August 02, 2013, 06:31:43 AM »
I've been having an issue that I can easily replicate in the ExampleMenu samples that come with TNet.  If I create a server on the menu screen of Example Menu and then stop the server, Unity hangs and I get the OS X Color Pinwheel for several minutes.  During that time Unity is unresponsive and sometimes it never comes back.  Now that I'm trying to write my own demo where a client looks for a sever and if there isn't one, it goes ahead and creates one.  The problem I'm having with my work flow is that every time I stop Unity, it hangs for several minutes.  This is very annoying and makes it impossible to work.  I've tried putting code to stop the server OnApplicationQuit() but that doesn't seem to help.  This does not seem to happen when I run the server beforehand via terminal, but unfortunately, using the server via terminal is not really what I need to deliver.  This happens on both my 27'' iMac (2012) and my 15'' Macbook Pro (2009) running Mountian Lion.  (Although the laptop seems to recover faster and more reliably)

I'm using Unity 4.2 and TNet 1.7.2c.  If relevant I'm using a DLINK DIR-826L router.

Does anyone have any ideas as to why this is happening?  Software on my machine?  Bad configuration?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #1 on: August 02, 2013, 02:55:19 PM »
Yes, I've seen an issue like that before leaving for Copenhagen, but trying to reproduce it there failed. Got back, same thing... unable to reproduce. I tried it in the Starlink repository though. I'll give the current TNet repository a try and see if I can reproduce it. If I can, I can certainly fix it (and will).

masterhyjinx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #2 on: August 02, 2013, 03:12:27 PM »
Thanks for the reply.  If there's more information that I could provide just let me know.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #3 on: August 02, 2013, 09:50:53 PM »
Try as I could, I wasn't able to reproduce it with the latest version (1.7.3), so I've pushed out that update to everyone. Let me know if you still run into it after updating to 1.7.3.

masterhyjinx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #4 on: August 03, 2013, 06:08:47 AM »
Still the same issue in 1.7.3
Testing the Example Menu scene, I start a server and then wait until I see it up and running, then I stop it. I started stepping through the code, to see at what line the game was hanging.  Right now, starting at "TNServerInstance.Stop("server.dat");" in Draw Connect Menu, if I step in further, when I step over "fileName = CleanupFilename(fileName);"  (This line is line 1204 in TNGameServer.cs), is when all of a sudden the editor hangs and mono develop goes no where.  (If I step into that line, I get into TNFileServer.cs and the hang happens there)

  1. public void SaveTo (string fileName)
  2.         {
  3. #if !UNITY_WEBPLAYER && !UNITY_FLASH
  4.                 if (mListener == null) return;
  5.                 fileName = CleanupFilename(fileName);       <--- Here
  6.                 FileStream stream;

I hope this helps.  I'm kinda bummed out that it's broken.

masterhyjinx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #5 on: August 03, 2013, 06:29:00 AM »
I'm flabbergasted right now.  So I tried to remove the string from "TNServerInstance.Stop ();" in DrawConnectMenu to avoid cleaning up the file name that was happening in my previous post.  The hang still occurs, but it does so here:

  1.         public void Stop ()
  2.         {
  3.                 if (lobbyLink != null) lobbyLink.Stop();
  4.  
  5.                 mAllowUdp = false;
  6.  
  7.                 // Stop the worker thread
  8.                 if (mThread != null)
  9.                 {
  10.                         mThread.Abort();
  11.                         mThread = null;
  12.                 }
  13.  
  14.                 // Stop listening
  15.                 if (mListener != null)          <--- Game hangs here now
  16.                 {
  17.                         mListener.Stop();
  18.                         mListener = null;
  19.                 }
  20.  

This makes zero sense to me since I can see mListener is not null right before I step over the line.  I'm going to import the project into a fresh Unity Project.  I'm suspecting that something has gone horribly wrong somewhere.

masterhyjinx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #6 on: August 03, 2013, 06:50:56 AM »
Vanilla project with just TNet in it.  Still hangs.  So I went a different direction.  I turned off my WiFi.  The server starts up no problem but of course throws warnings about no route to host and uPnP.  So I connect to the public WiFi here at my apartment complex and try.  The server start up and shut down works great.  Huh...

After poking around with my router, I turn off uPnP on it.  Now I can start and stop a server with no problem at all.  The only warning I get is "UPnP discovery failed (Operation timed out)".  So I'm assuming that the locations of the hangs I was getting before just coincided with something else?  At this point it's almost 5 a.m. so I'm going to sleep.  I'll try again tomorrow.

I've also attached a screenshot of my router model number and firmware just to provide the most information.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #7 on: August 03, 2013, 02:32:55 PM »
Hmm... that does seem very strange, and I'm also guessing that the hang is not caused by the lines pointed out below. Something in the UPnP -- likely in the destructor -- I am guessing the part where it calls "WaitForThreads()". First, try commenting out this line in TNUPnP.Close():
  1. if (mStatus != Status.Success)
If that doesn't work, try replacing UPnP.WaitForThreads function with this:
  1.         public void WaitForThreads ()
  2.         {
  3.                 for (int i = 0; mThreads.size > 0 && i < 2000; ++i)
  4.                         Thread.Sleep(1);
  5.         }

masterhyjinx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #8 on: August 03, 2013, 05:50:24 PM »
Commenting out the line
  1. if (mStatus != Status.Success)
results in no change in behavior.

I replaced
  1. public void WaitForThreads () { while (mThreads.size > 0) Thread.Sleep(1); }
in UPnP with:
  1.     public void WaitForThreads ()
  2.     {
  3.         for (int i = 0; mThreads.size > 0 && i < 2000; ++i)
  4.             Thread.Sleep(1);
  5.     }

again with no change in behavior.  Unity will still lock up for a minute or two and it either comes back or complete locks up until I terminate it.

masterhyjinx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #9 on: August 03, 2013, 09:19:18 PM »
Ok, status update.  After mucking with it all day, it appears that the culprit is the way the server interacts with my router.  My router, the DLink DIR-826L and its line of routers apparently have a spotty record when it comes to uPnP.  (Maybe all routers do?)  Anyways, I tested 2 other routers and the hangs do not occur.  Everything runs fine.  One router isn't mine and the other router is the last one I replaced because it fails after running for an hour or so.

Here's the output if I run the server from terminal on my DLink DIR-826L
  1. Wenceslaos-iMac:Debug wenceslaovillanueva$ mono TNServer.exe -name "Jay Server" -tcp 5127 -udp 5128 -udpLobby 5129
  2. IP Addresses
  3. ------------
  4. External: 97.120.193.31
  5. Internal: 192.168.1.9
  6. Gateway:  192.168.1.1
  7.  
  8. UDP Lobby Server started on port 5129
  9. Game server started on port 5127
  10. Press 'q' followed by ENTER when you want to quit.
  11.  
  12. ** (TNServer.exe:5345): WARNING **: _wapi_connect: error looking up socket handle 0xa (error 10050)
  13. UPnP: Unable to open TCP port 5127
  14. UPnP: Unable to open UDP port 5129
  15. UPnP: Unable to open UDP port 5128

If I stop the server running in terminal, the terminal hangs for a couple minutes before it actually exits.  Similar to the way Unity hangs when I stop it.  For my purposes, it's ok if UPnP fails.  I'm targeting only running this demo on LAN at a show.  The only thing that is killing me is the fact that the server hangs thus killing my workflow.  So, to get things done in the short run, I think I'm going to go buy another router unless there's a way to disable UPnP or correct the way it interacts with my router.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #10 on: August 04, 2013, 12:20:51 AM »
Hmm... Well, the UPnP request gets sent in UPnP.SendRequest function. It contains a timeout, and it may repeat the message if the first try fails.

In UPnP.Close function, it will attempt to close the port, waiting there until it's actually closed. Could the router be sending something that it has trouble with? Have you tried printing out what the router is sending back? You can print it inside UPnP.SendRequest function on line 284.

masterhyjinx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #11 on: August 04, 2013, 03:49:13 AM »
Inside the try block in SendRequest I put a Debug.Log for the response like so:
  1. try
  2.                 {
  3.                         for (int i = 0; i < repeat; ++i)
  4.                         {
  5.                                 WebRequest web = HttpWebRequest.Create(mControlURL);
  6.                                 web.Timeout = timeout;
  7.                                 web.Method = "POST";
  8.                                 web.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:" + mServiceType + ":1#" + action + "\"");
  9.                                 web.ContentType = "text/xml; charset=\"utf-8\"";
  10.                                 web.ContentLength = b.Length;
  11.                                 web.GetRequestStream().Write(b, 0, b.Length);
  12.                                 response = Tools.GetResponse(web);
  13.                                 UnityEngine.Debug.Log("Response:\n" + response);
  14.                                 if (!string.IsNullOrEmpty(response))
  15.                                         return response;
  16.                         }
  17.                 }

Here's the list of responses I got for opening MainMenu, starting the server and then stopping it.

  1. Response:
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:AddPortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"/></s:Body></s:Envelope>
  4.  

  1. Response:
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:AddPortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"/></s:Body></s:Envelope>
  4.  

Then I clicked stop the local server.  None of the following messages appeared until after Unity un-froze.

  1. Response:
  2.  

  1. Response:
  2.  

  1. Response:
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:DeletePortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:DeletePortMappingResponse></s:Body></s:Envelope>
  4.  

  1. Response:
  2.  

  1. Response:
  2.  

  1. Response:
  2.  

  1. Response:
  2.  

  1. Response:
  2.  

  1. Response:
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:DeletePortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:DeletePortMappingResponse></s:Body></s:Envelope>
  4.  

I tried this a couple more times and it seems the order I get them in is a little different.  Is this the sort of output you expect?  Can I get some more information?  The guys I'm doing this for already got me a new router to use for this project.  I'll be setting this one up but I'll leave the old one here just in case I need to test something for you.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #12 on: August 04, 2013, 07:00:27 AM »
Can you put a Debug.Log with the current time above GetResponse() call as well (and add the current time to the current Debug.Log you have in there?)

I'm curious if the GetResponse part is where it hangs.

masterhyjinx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #13 on: August 04, 2013, 02:19:55 PM »
So now the code reads as:
  1. try
  2.                 {
  3.                         for (int i = 0; i < repeat; ++i)
  4.                         {
  5.                                 WebRequest web = HttpWebRequest.Create(mControlURL);
  6.                                 web.Timeout = timeout;
  7.                                 web.Method = "POST";
  8.                                 web.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:" + mServiceType + ":1#" + action + "\"");
  9.                                 web.ContentType = "text/xml; charset=\"utf-8\"";
  10.                                 web.ContentLength = b.Length;
  11.                                 web.GetRequestStream().Write(b, 0, b.Length);
  12.                                 UnityEngine.Debug.Log(action + " --" + " Time Before Response: " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));
  13.                                 response = Tools.GetResponse(web);
  14.                                 UnityEngine.Debug.Log(action + " --" +" Response:\n" + response + "\n Time After Response: " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));
  15.                                 if (!string.IsNullOrEmpty(response))
  16.                                         return response;
  17.                         }
  18.                 }

This morning, with everyone asleep and no on on the router.  I noticed that the hang wasn't as long as it was yesterday, maybe 30-45 seconds?  Maybe current use has some factor (Starting to think I should just chuck the old router out the window).  So two things happened.  This morning after putting those prints in, I noticed that if I start the server, then waited a few seconds, then stopped it I didn't receive any more output, there was still a hang but no more output.  The "DeletePortMapping" events never occurred.  So this time I waited until I saw a few more AddPortMappings to my output, THEN I stopped the server and the game hung.

Here's all the output:

  1. AddPortMapping -- Time Before Response: 08/04/2013 12:04:25.349 PM
  2.  
  3.  
  4. AddPortMapping -- Time Before Response: 08/04/2013 12:04:25.354 PM
  5.  
  6.  
  7. AddPortMapping -- Time Before Response: 08/04/2013 12:04:25.349 PM
  8.  
  9.  
  10. AddPortMapping -- Response:
  11.  Time After Response: 08/04/2013 12:04:25.357 PM
  12.  
  13.  
  14. AddPortMapping -- Response:
  15.  Time After Response: 08/04/2013 12:04:35.361 PM
  16.  
  17.  
  18. AddPortMapping -- Response:
  19.  Time After Response: 08/04/2013 12:04:35.361 PM
  20.  
  21.  
  22. AddPortMapping -- Time Before Response: 08/04/2013 12:04:35.363 PM
  23.  
  24.  
  25. AddPortMapping -- Time Before Response: 08/04/2013 12:04:35.364 PM
  26.  
  27. AddPortMapping -- Response:
  28.  Time After Response: 08/04/2013 12:04:35.368 PM
  29.  
  30.  
  31. AddPortMapping -- Time Before Response: 08/04/2013 12:04:35.369 PM
  32.  
  33.  
  34. AddPortMapping -- Response:
  35. <?xml version="1.0" encoding="UTF-8"?>
  36. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:AddPortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"/></s:Body></s:Envelope>
  37.  
  38.  Time After Response: 08/04/2013 12:04:35.376 PM
  39.  
  40.  
  41. AddPortMapping -- Response:
  42.  Time After Response: 08/04/2013 12:04:45.371 PM
  43.  
  44.  
  45. DeletePortMapping -- Time Before Response: 08/04/2013 12:04:54.623 PM
  46. UnityEngine.Debug:Log(Object)
  47. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:314)
  48. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  49. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  50. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  51. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  52. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  53. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  54. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  55. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  56. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  57.  
  58.  
  59. DeletePortMapping -- Response:
  60.  Time After Response: 08/04/2013 12:05:04.629 PM
  61. UnityEngine.Debug:Log(Object)
  62. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:316)
  63. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  64. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  65. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  66. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  67. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  68. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  69. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  70. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  71. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  72.  
  73.  
  74. DeletePortMapping -- Time Before Response: 08/04/2013 12:05:04.638 PM
  75. UnityEngine.Debug:Log(Object)
  76. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:314)
  77. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  78. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  79. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  80. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  81. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  82. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  83. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  84. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  85. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  86.  
  87.  
  88. DeletePortMapping -- Response:
  89.  Time After Response: 08/04/2013 12:05:14.639 PM
  90. UnityEngine.Debug:Log(Object)
  91. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:316)
  92. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  93. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  94. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  95. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  96. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  97. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  98. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  99. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  100. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  101.  
  102.  
  103. DeletePortMapping -- Time Before Response: 08/04/2013 12:05:14.657 PM
  104. UnityEngine.Debug:Log(Object)
  105. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:314)
  106. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  107. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  108. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  109. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  110. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  111. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  112. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  113. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  114. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  115.  
  116.  
  117. DeletePortMapping -- Response:
  118.  Time After Response: 08/04/2013 12:05:24.659 PM
  119. UnityEngine.Debug:Log(Object)
  120. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:316)
  121. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  122. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  123. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  124. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  125. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  126. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  127. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  128. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  129. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  130.  
  131.  
  132. DeletePortMapping -- Time Before Response: 08/04/2013 12:05:24.663 PM
  133. UnityEngine.Debug:Log(Object)
  134. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:314)
  135. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  136. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  137. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  138. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  139. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  140. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  141. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  142. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  143. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  144.  
  145.  
  146. DeletePortMapping -- Response:
  147. <?xml version="1.0" encoding="UTF-8"?>
  148. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:DeletePortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:DeletePortMappingResponse></s:Body></s:Envelope>
  149.  
  150.  Time After Response: 08/04/2013 12:05:24.673 PM
  151. UnityEngine.Debug:Log(Object)
  152. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:316)
  153. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  154. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  155. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  156. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  157. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  158. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  159. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  160. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  161. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  162.  
  163.  
  164. DeletePortMapping -- Time Before Response: 08/04/2013 12:05:24.691 PM
  165. UnityEngine.Debug:Log(Object)
  166. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:314)
  167. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  168. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  169. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  170. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  171. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  172. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  173. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  174. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  175. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  176.  
  177.  
  178. DeletePortMapping -- Response:
  179.  Time After Response: 08/04/2013 12:05:34.693 PM
  180. UnityEngine.Debug:Log(Object)
  181. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:316)
  182. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  183. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  184. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  185. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  186. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  187. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  188. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  189. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  190. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  191.  
  192.  
  193. DeletePortMapping -- Time Before Response: 08/04/2013 12:05:34.697 PM
  194. UnityEngine.Debug:Log(Object)
  195. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:314)
  196. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  197. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  198. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  199. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  200. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  201. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  202. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  203. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  204. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  205.  
  206.  
  207. DeletePortMapping -- Response:
  208.  Time After Response: 08/04/2013 12:05:44.699 PM
  209. UnityEngine.Debug:Log(Object)
  210. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:316)
  211. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  212. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  213. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  214. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  215. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  216. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  217. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  218. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  219. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  220.  
  221.  
  222. DeletePortMapping -- Time Before Response: 08/04/2013 12:05:44.708 PM
  223. UnityEngine.Debug:Log(Object)
  224. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:314)
  225. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  226. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  227. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  228. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  229. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  230. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  231. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  232. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  233. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  234.  
  235.  
  236. DeletePortMapping -- Response:
  237.  Time After Response: 08/04/2013 12:05:54.709 PM
  238. UnityEngine.Debug:Log(Object)
  239. TNet.UPnP:SendRequest(String, String, Int32, Int32) (at Assets/TNet/Common/TNUPnP.cs:316)
  240. TNet.UPnP:SendRequest(ExtraParams) (at Assets/TNet/Common/TNUPnP.cs:465)
  241. TNet.UPnP:CloseRequest(Object) (at Assets/TNet/Common/TNUPnP.cs:457)
  242. TNet.UPnP:Close(Int32, Boolean, OnPortRequest) (at Assets/TNet/Common/TNUPnP.cs:435)
  243. TNet.UPnP:Close() (at Assets/TNet/Common/TNUPnP.cs:134)
  244. TNServerInstance:Disconnect() (at Assets/TNet/Client/TNServerInstance.cs:263)
  245. TNServerInstance:Stop() (at Assets/TNet/Client/TNServerInstance.cs:229)
  246. TNServerInstance:Stop(String) (at Assets/TNet/Client/TNServerInstance.cs:240)
  247. ExampleMenu:DrawConnectMenu() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:128)
  248. ExampleMenu:OnGUI() (at Assets/TNet/Examples/Scripts/ExampleMenu.cs:77)
  249.  

masterhyjinx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Unity hangs when TNet server is stopped
« Reply #14 on: August 04, 2013, 02:54:48 PM »
So what is your assessment Arenmook?  Is the DLink DIR-826L a piece of junk?  It's brand new unfortunately.  I don't invest TOO much into routers because it seems I have to replace them each year.

The guys I'm doing this for replaced my router for the time being with an Asus Dual-Band Wireless-AC1750 router:  http://www.asus.com/us/Networking/RTAC66U

After hooking it up and doing basic configuration I tested it.  Works great, server in terminal and in Unity.  No hangs.  Here's the output:

  1. AddPortMapping -- Time Before Response: 08/04/2013 12:44:34.041 PM
  2.  
  3. AddPortMapping -- Time Before Response: 08/04/2013 12:44:34.044 PM
  4.  
  5. AddPortMapping -- Time Before Response: 08/04/2013 12:44:34.041 PM
  6.  
  7.  
  8. AddPortMapping -- Response:
  9. <?xml version="1.0"?>
  10. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:AddPortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"/></s:Body></s:Envelope>
  11.  Time After Response: 08/04/2013 12:44:34.049 PM
  12.  
  13.  
  14. AddPortMapping -- Response:
  15. <?xml version="1.0"?>
  16. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:AddPortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"/></s:Body></s:Envelope>
  17.  Time After Response: 08/04/2013 12:44:34.049 PM
  18.  
  19.  
  20. AddPortMapping -- Response:
  21. <?xml version="1.0"?>
  22. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:AddPortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"/></s:Body></s:Envelope>
  23.  Time After Response: 08/04/2013 12:44:34.054 PM
  24.  
  25.  
  26. Stop the server a few seconds later:
  27.  
  28.  
  29. DeletePortMapping -- Time Before Response: 08/04/2013 12:44:41.565 PM
  30. UnityEngine.Debug:Log(Object)
  31.  
  32.  
  33. DeletePortMapping -- Response:
  34. <?xml version="1.0"?>
  35. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:DeletePortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:DeletePortMappingResponse></s:Body></s:Envelope>
  36.  Time After Response: 08/04/2013 12:44:41.570 PM
  37.  
  38. DeletePortMapping -- Time Before Response: 08/04/2013 12:44:41.572 PM
  39.  
  40.  
  41. DeletePortMapping -- Response:
  42. <?xml version="1.0"?>
  43. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:DeletePortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:DeletePortMappingResponse></s:Body></s:Envelope>
  44.  Time After Response: 08/04/2013 12:44:41.579 PM
  45.  
  46.  
  47. DeletePortMapping -- Time Before Response: 08/04/2013 12:44:41.581 PM
  48.  
  49.  
  50. DeletePortMapping -- Response:
  51. <?xml version="1.0"?>
  52. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:DeletePortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:DeletePortMappingResponse></s:Body></s:Envelope>
  53.  Time After Response: 08/04/2013 12:44:41.585 PM

From terminal:

  1. $ mono TNServer.exe -name "Jay Server" -tcp 5127 -udp 5128 -udpLobby 5129
  2. IP Addresses
  3. ------------
  4. External: 67.5.151.146
  5. Internal: 192.168.1.9
  6. Gateway:  192.168.1.1
  7.  
  8. UDP Lobby Server started on port 5129
  9. Game server started on port 5127
  10. Press 'q' followed by ENTER when you want to quit.
  11. UPnP: UDP port 5129 was opened successfully.
  12. UPnP: TCP port 5127 was opened successfully.
  13. UPnP: UDP port 5128 was opened successfully.
  14. q
  15. Shutting down...
  16. There server has shut down. Press ENTER to terminate the application.