Author Topic: 2 minute blocking timeout on connect.  (Read 5832 times)

grey

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 3
    • View Profile
2 minute blocking timeout on connect.
« on: June 26, 2014, 12:40:59 AM »
Hi guys, got an 'interesting' problem for you.

 I've been using TNet for a little while now, quite successfully. Recently I decided to use my 30-day pro trial for Unity, and upon that trial expiring, TNet appears to have fallen into an odd 2-minute lock-up timeout when trying to connect.

 This lock-up does not occur if my project is built using a pro version of Unity, and does not occur within the editor.

 I have created a trivial test-case:

 

 attached it to an object in an otherwise blank scene.

 I then add two debug lines to TNTcpProtocol.cs like so:

 

 and then build said project like so:

 

 finally, I wait the 2 minutes for the build to unfreeze and have the following to see:

 

 I can provide the entire project (512kb compressed) upon request as well. (I won't just add it here as it contains the entire TNet source of course.)

 Just in case it is at all relevant, I am running Windows 8.1. This has not changed in the time I have been using TNet but I don't know how sockets work anywhere near well enough to know if that's useful information.

 Additionally, I was using version 1.9.1, the latest version (1.9.5c I believe) has not solved the problem either.

 edit: one more piece of info; Unity v 4.5.0f6

 Anyone have any ideas on how I can fix this?

 Cheers!
« Last Edit: June 26, 2014, 12:46:49 AM by grey »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 2 minute blocking timeout on connect.
« Reply #1 on: June 26, 2014, 11:59:24 AM »
That does sound "interesting". It only started happening after your Unity reverted from Pro to indie? My suggestion is replace "localhost" with "127.0.0.1".

P.S. Note that the Connect request exists immediately. Actual connection response comes later via OnNetworkConnect. Your "connection successful" message is in the wrong place.

grey

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: 2 minute blocking timeout on connect.
« Reply #2 on: June 26, 2014, 05:41:14 PM »
Changing my connection from "localhost" to "127.0.0.1" did not solve anything sadly.

 And yes, this oddity began when Unity reverted from Pro to Indie. This *may* not be the actual problem, but it is the only significant change that happened on my project between using TNet successfully and not. (I've eliminated other changes as factors by creating an entirely new project as described in my original post.)

 As for your note on my 'connection successful' message. That's actually a good indication. The log message does not appear until after my "2 minutes" messages, which suggests to me that the main Unity thread is being blocked by the work done within the Async thread.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 2 minute blocking timeout on connect.
« Reply #3 on: June 27, 2014, 02:15:05 PM »
That doesn't make sense. Why would Unity wait on a secondary thread? Can you add more debugging there determining exactly which call is causing it to wait? It does sound like a pretty weird Unity bug.

grey

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: 2 minute blocking timeout on connect.
« Reply #4 on: June 27, 2014, 05:49:26 PM »
So I added a ton of debugging lines to OnConnectResult. Made no other changes whatsoever and... it works correctly.

-_-

Reverting my changes doesn't re-break the build either, so I'm at a bit of a loss now. *sigh* I now suspect the magic gnomes living inside windows are at fault. :P Maybe they were on strike or something...

Thank you ArenMook, for your time. Hopefully I won't be back with more strange bugs like this in the future. For now, I'm going to just go with it, and hope it keeps behaving.