question

Dan Wilson avatar image
Dan Wilson asked

Server Aync methods, issues...

I am trying to utilize the RedeemMatchMakerTicket call...

I am having issues getting the async methods to work.

I found several entries here in the forums about deadlocking, and have tried all the proposed solutions and nothing is working.

If I try to simply await the playfab method in an Async function, the application crashes, like this

public async void RedeemMatchMakerTicket(IClient client, string lobbyID, string ticket) { 

RedeemMatchmakerTicketRequest request = new RedeemMatchmakerTicketRequest(); 
request.LobbyId = lobbyID; 
request.Ticket = ticket; 

var response = await PlayFabServerAPI.RedeemMatchmakerTicketAsync(request).ConfigureAwait(false); 

if (response.Error != null) { WriteLog(response.Error.ErrorMessage, LogType.Error); } 

if (response.Result != null) { RedeemTicketCallback(client, response.Result); } 

}

If instead I try to manually run a task, as outlined here in the forums, i get an exception pointing at the DoPost method in the server sdk, like this

public void RedeemMatchMakerTicket(IClient client, string lobbyID, string ticket) 
{ 

RedeemMatchmakerTicketRequest request = new RedeemMatchmakerTicketRequest(); 
request.LobbyId = lobbyID; 
request.Ticket = ticket; 

bool working = true; 
var response = PlayFabServerAPI.RedeemMatchmakerTicketAsync(request); 
response.ContinueWith((result)=>{ working = false; }); 

while(working) { Console.Write("working..."); } 

if (response.Exception != null) { WriteLog(response.Exception.Message, LogType.Error); } 
if (response.Result != null) { RedeemTicketCallback(client, response.Result); } 

}

I get this exception

at PlayFab.Internal.PlayFabHttp.<DoPost>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at PlayFab.PlayFabServerAPI.<RedeemMatchmakerTicketAsync>d__67.MoveNext()

Any ideas?

Custom Game Servers
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

It's a bit tough to debug without the repro case. Can you try using our sample server (https://github.com/PlayFab/PlayFabGameServer), and see if that works for you? If not, do you have a small repro project you can send to us?

13 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dan Wilson avatar image Dan Wilson commented ·

I can certainly send you something, where/whom do i send it to?

I am using DarkRift as my server, and as I understand the way async in C# is supposed to be used, it's supposed to be used all the way thru, but I can't do that, since DR is firing an event that I am listening for when a client sends the server a message.

I have been going through many solutions on the net, and so far nothing has worked, attempting to run an async method from a sync method.

On my Win 10 box it works, but on the PF instance I get the aforementioned exception.

My setup is all .Net 4.5

Since it works on my box calling the PlayfabServerAPI, I am guessing there isn't something wrong with the API itself, but perhaps with Win2012 R2?


0 Likes 0 ·
Dan Wilson avatar image Dan Wilson commented ·

This code executes correctly on my local instance of the server (Win10), I get a playfab error obviously since the ticket I am passing isn't valid, but that at least is working.

On the Gameserver I get an exception running the same code, pointing to the DoPost method in the playfab server api, coming from the line PlayFabServerAPI.RedeemMatchmakerTicketAsync(request));

public void RedeemMatchMakerTicket(IClient client, string lobbyID, string ticket)
        {
            RedeemMatchmakerTicketRequest request = new RedeemMatchmakerTicketRequest();
            request.LobbyId = lobbyID;
            request.Ticket = ticket;
            var response = Task.Run<PlayFabResult<RedeemMatchmakerTicketResult>>(async()=> await PlayFabServerAPI.RedeemMatchmakerTicketAsync(request));
            var result = response.Result;
            if (result != null)
            {
                RedeemTicketCallback(client, result);
            }
            else
            {
                WriteLog("result is null", LogType.Error);
            }
        }
0 Likes 0 ·
brendan avatar image brendan Dan Wilson commented ·

There are enough differences between Win10 and Windows Server 2K12 R2 that I can't really recommend Win10 as your platform for testing your server code. What I'd recommend at this point is reaching out to the DarkRift team for feedback, though you may want to first put a try/catch in there, to see if you can get additional details from the exception that's thrown. The issue would appear to be related to the async handler logic in the engine itself.

0 Likes 0 ·
Dan Wilson avatar image Dan Wilson brendan commented ·

Ok So I have a Win 2012 R2 VM running, and i run my software, pass in all the params, and it works.

The call to redeem the matchmaking ticket returns an error from playfab, because obviously the matchmaking ticket is phony, but it is working.

Could this mean that somehow the actual ticket response is messing up when a real ticket is sent?

I guess I can try running the server on PF, and get a matchmaking ticket, and run another client connected to my local VM and pass the ticket to that server, and see if it can complete the call

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.