Forum Multiplayer This must be a bug.

Discussion and help relating to the PlayerIO Multiplayer API.

This must be a bug.

Postby Vania » May 13th, 2010, 2:46 am

I've been testing locally for some time now, without problems.

Now that I uploaded to the server I get a very strange error:

Code for event Started ran for too long
1014ms. The maximum runtime is 100ms

at System.Net.UnsafeNclNativeMethods.WinHttp.WinHttpDetectAutoProxyConfigUrl(UInt32 autoDetectFlags, SafeGlobalFree& autoConfigUrl)
at System.Net.AutoWebProxyScriptEngine.SafeDetectAutoProxyUrl(UInt32 discoveryMethod)
at System.Net.AutoWebProxyScriptEngine.AutoDetector.DetectScriptLocation()
at System.Net.AutoWebProxyScriptEngine.EnsureEngineAvailable(Int32& syncStatus)
at System.Net.AutoWebProxyScriptEngine.GetProxies(Uri destination, Boolean returnFirstOnly, AutoWebProxyState& autoWebProxyState, Int32& syncStatus)
at System.Net.WebProxy.GetProxiesAuto(Uri destination, AutoWebProxyState& autoWebProxyState, Int32& syncStatus)
at System.Net.ProxyScriptChain.GetNextProxy(Uri& proxy)
at System.Net.ProxyChain.ProxyEnumerator.MoveNext()
at System.Net.ServicePointManager.FindServicePoint(Uri address, IWebProxy proxy, ProxyChain& chain, HttpAbortDelegate& abortDelegate, Int32& abortState)
at System.Net.HttpWebRequest.FindServicePoint(Boolean forceFind)
at System.Net.HttpWebRequest.BeginGetRequestStream(AsyncCallback callback, Object state)
at ServersideGameCode.GameCode.GameStarted()



As you can see the error originates from the GameStarted() method, it says it is running too long. here's the method, it's really small and simple:

Code: Select all
public override void GameStarted() {

            roomState = FILLING_UP;
            Visible = true;
            paused = false;
            endTurnMsgs = new Dictionary<int,Dictionary<int,Message>>();

            var np = RoomData["players"];
            switch (np) {
                case "1":
                    numPlayers = 1;
                    break;
                case "2":
                    numPlayers = 2;
                    break;
                case "3":
                    numPlayers = 3;
                    break;
                case "4":
                    numPlayers = 4;
                    break;
            }
            password = RoomData["password"];
            activePlayers = 0;
            armiesAvailable = new List<int>();

            for (var i = 1; i <= numPlayers; i++)
            {
                armiesAvailable.Add(i);
            }
}


Nothing fancy there.

Now, the strange thing is not only that I dont get this in my local server,
but that if I open 3 instances of the game then the third one works!

I've repeated the procedure many times, and as long as I open 2 instances before I dont get an error for the third one,
that is: I create 2 rooms and the third one works.


I cant think of an explanation for this weird behavior, any ideas?
Vania
 
Posts: 198
Joined: March 24th, 2010, 9:01 pm

Re: This must be a bug.

Postby Oliver » May 13th, 2010, 11:30 am

Hi Vania,

This is indeed a bug.

What's happening is that you're changing the Visible property of the room, which causes a web request to fire off to the
main Player.IO webservice to inform it that the room should now have a different visibility.

The request is supposed to be fired asynchronously, but it seems that the framework sometimes takes a dis-proportionally long time to just queue up the request.

I've noted this on the To-Fix list.

If you're just setting Visible to true, a simple workaround wouldbe to just remove the the line and set the room to visible by default in the call to createRoom() ?

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: This must be a bug.

Postby Vania » May 13th, 2010, 10:16 pm

If you're just setting Visible to true, a simple workaround wouldbe to just remove the the line and set the room to visible by default in the call to createRoom() ?


Sounds good, I´ll do that.

I do need to change the visibility when the room fills up with the maximum number of players,
but that can wait till the bug is fixed. Thx.
Vania
 
Posts: 198
Joined: March 24th, 2010, 9:01 pm

Re: This must be a bug.

Postby fox1980 » May 14th, 2010, 12:48 am

A bit offtopic, but you can use

Code: Select all
numPlayers=Convert.ToInt32(np);


instead of

Code: Select all
            switch (np) {
                case "1":
                    numPlayers = 1;
                    break;
                case "2":
                    numPlayers = 2;
                    break;
                case "3":
                    numPlayers = 3;
                    break;
                case "4":
                    numPlayers = 4;
                    break;
            }
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: This must be a bug.

Postby Vania » May 14th, 2010, 1:12 am

Oh cool, I tried to use the parse() in int but it uses an "out" parameter, which I think is forbidden.
Thanks.
Vania
 
Posts: 198
Joined: March 24th, 2010, 9:01 pm

Re: This must be a bug.

Postby Oliver » May 17th, 2010, 10:25 am

Both of these should be okay:

Code: Select all
   int value;
   int.TryParse("123", out value);

   int otherValue = int.Parse("123");


- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: This must be a bug.

Postby Oliver » June 3rd, 2010, 9:09 am

Hi,

Just a short note to let you know that the original issue mentioned (code ran for too long when setting the visible property) should be fixed in v1.5.1 which has just been released.

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am


Return to Multiplayer