Playfab example- error?

i’m testing https://github.com/britzl/playfabexamples in my desktop and only changing titleId. But when i’m running the app, it showing “logged in as anonymous (nil)”, highscore are blank ,registered and logged suddenly crash. i’m confused :confused:

Hi! Does it work if you keep the original titleId? What do you mean by “registered and logged suddenly crash”? Do you get an error message of some kind?

Hello, [quote=“britzl, post:2, topic:3581”]
Hi! Does it work if you keep the original titleId?
[/quote]
Nope, same error.[quote=“britzl, post:2, topic:3581”]
What do you mean by “registered and logged suddenly crash”?
[/quote]

it just keep looping “spinner”[quote=“britzl, post:2, topic:3581”]
Do you get an error message of some kind?
[/quote]

Yes," DEBUG:SCRIPT: WARN: flow.update() now requires dt. Assuming 0.0167 for now."

:confused:

The “WARN: flow.update() now requires dt. Assuming 0.0167 for now.” is caused by an update to one of the helper libraries that I didn’t take into account. I’ve pushed a new version of the PlayFab Example project to take care of this, but it really shouldn’t matter.

I tried the example project again and I couldn’t see any problems with it. I’ve attached a recording of a run here:

I wonder if there’s some corrupt auth data saved for the app? Could you please delete the cache for the “PlayFab_API_Example” app? On OSX files are stored under “user_folder/Library/Application Support/PlayfabAPI_Example/”, not sure where app specific files are stored on Windows though.

1 Like

Could you also try the following to the top of controller.script:

local http_request = http.request
http.request = function(url, method, callback, headers, post_data, options)
	print(url)
	pprint(post_data)
	http_request(url, method, function(self, id, response)
		pprint(response)
		callback(self, id, response)
	end, headers, post_data, options)
end

This will monkey-patch the http.request() function and always print the the request and server response. I wonder if you run into some issue when contacting the PlayFab server. An example of the response I get from the login when credentials are stored on disk:

DEBUG:SCRIPT: https://6DE1.playfabapi.com//Client/LoginWithPlayFab
DEBUG:SCRIPT: {"Username":"foobar12345678","Password":"qwerty","TitleId":"6DE1"}
DEBUG:SCRIPT: 
{
  status = 200,
  response = {"code":200,"status":"OK","data":{"SessionTicket":"8DF0DA863A208113-0-0-6DE1-8D41D0102FF577F-7A2F5B000FA4148F.A6F3BE2DFB05A862","PlayFabId":"8DF0DA863A208113","NewlyCreated":false,"SettingsForUser":{"NeedsAttribution":false},"LastLoginTime":"2016-12-05T11:22:23.546Z"}},
  headers = {
    content-type = application/json; charset=utf-8,
    connection = keep-alive,
    access-control-allow-methods = GET, POST,
    access-control-allow-headers = Content-Type, Content-Encoding, X-Authentication, X-Authorization, X-PlayFabSDK, X-ReportErrorAsSuccess, X-SecretKey,
    access-control-allow-credentials = true,
    content-length = 269,
    date = Mon, 05 Dec 2016 11:22:34 GMT,
    access-control-allow-origin = *,
    x-requestid = d45093ed7aa9492fa6df3c92c8543420,
    cache-control = private,
  }
}
1 Like

Question for you @britzl : Have you added/changed anything on the Playfab server side? Like added statistics counter or save data or edited something on the server script?

Hello again, i’m using new version and test it…

console output

INFO:ENGINE: Defold Engine 1.2.93 (f2c010d)
INFO:ENGINE: Loading data from: build/default
INFO:ENGINE: Initialised sound device 'default'

INFO:DLIB: SSDP: Started on address 192.168.1.2
DEBUG:SCRIPT: https://6DE1.playfabapi.com//Client/LoginWithCustomID
DEBUG:SCRIPT: {"CustomId":"}'Nv{<xPh*,:ccIel{%T","TitleId":"6DE1","CreateAccount":true}
DEBUG:SCRIPT: 
{
  status = 200,
  response = {"code":200,"status":"OK","data":{"SessionTicket":"BB8BFF9146B0FD47---6DE1-8D41D0A7801A115-AA5A52BE914D44EC.A5253887B9928E09","PlayFabId":"BB8BFF9146B0FD47","NewlyCreated":true,"SettingsForUser":{"NeedsAttribution":false},"LastLoginTime":"2016-12-05T12:30:16.577Z"}},
  headers = {
    content-type = application/json; charset=utf-8,
    connection = keep-alive,
    access-control-allow-methods = GET, POST,
    access-control-allow-headers = Content-Type, Content-Encoding, X-Authentication, X-Authorization, X-PlayFabSDK, X-ReportErrorAsSuccess, X-SecretKey,
    access-control-allow-credentials = true,
    content-length = 266,
    date = Mon, 05 Dec 2016 12:30:15 GMT,
    access-control-allow-origin = *,
    x-requestid = d72338892ae04316a74c61b875e143cf,
    cache-control = private,
  }
}

DEBUG:SCRIPT: https://6DE1.playfabapi.com//Client/GetUserData
DEBUG:SCRIPT: []
DEBUG:SCRIPT: https://6DE1.playfabapi.com//Client/GetLeaderboardAroundPlayer
DEBUG:SCRIPT: {"StatisticName":"score"}
DEBUG:SCRIPT: Warning: Flow resulted in error	ludobits/m/savefile.lua:41: Could not write to the file \s4pg..
DEBUG:SCRIPT: 
{
  status = 200,
  response = {"code":200,"status":"OK","data":{"Leaderboard":[{"PlayFabId":"887B859589FDDBEA","DisplayName":"wwwaaawwwaa","StatValue":100,"Position":38},{"PlayFabId":"B039227CF2BBEF00","StatValue":100,"Position":39},{"PlayFabId":"B8F8AC5448DE45C7","StatValue":100,"Position":40},{"PlayFabId":"C255314815E1BE85","StatValue":100,"Position":41},{"PlayFabId":"CF78CEE576B7E852","StatValue":100,"Position":42},{"PlayFabId":"BB8BFF9146B0FD47","StatValue":0,"Position":43},{"PlayFabId":"784B3DDF39996FD4","StatValue":0,"Position":44},{"PlayFabId":"6BABE7B85A419DCE","StatValue":0,"Position":45},{"PlayFabId":"6A37706BB7E27031","StatValue":0,"Position":46},{"PlayFabId":"62297447EB47D31A","StatValue":0,"Position":47}]}},
  headers = {
    content-type = application/json; charset=utf-8,
    connection = keep-alive,
    access-control-allow-methods = GET, POST,
    access-control-allow-headers = Content-Type, Content-Encoding, X-Authentication, X-Authorization, X-PlayFabSDK, X-ReportErrorAsSuccess, X-SecretKey,
    access-control-allow-credentials = true,
    content-length = 699,
    date = Mon, 05 Dec 2016 12:30:16 GMT,
    access-control-allow-origin = *,
    x-requestid = ad0a541409674917be3a553e2d38d9dc,
    cache-control = private,
  }
}

DEBUG:SCRIPT: 
{
  status = 200,
  response = {"code":200,"status":"OK","data":{"Data":{},"DataVersion":0}},
  headers = {
    content-type = application/json; charset=utf-8,
    connection = keep-alive,
    access-control-allow-methods = GET, POST,
    access-control-allow-headers = Content-Type, Content-Encoding, X-Authentication, X-Authorization, X-PlayFabSDK, X-ReportErrorAsSuccess, X-SecretKey,
    access-control-allow-credentials = true,
    content-length = 61,
    date = Mon, 05 Dec 2016 12:30:18 GMT,
    access-control-allow-origin = *,
    x-requestid = 788c5fd3d2fc4b68840f9957430776ef,
    cache-control = private,
  }
}

DEBUG:SCRIPT: 
{
  Email = helpcare@god.ch,
  Password = help,
  Username = savemegod,
}

DEBUG:SCRIPT: https://6DE1.playfabapi.com//Client/AddUsernamePassword
DEBUG:SCRIPT: {"Email":"helpcare@god.ch","Password":"help","Username":"savemegod"}
DEBUG:SCRIPT: 
{
  status = 200,
  response = {"code":400,"status":"BadRequest","error":"InvalidParams","errorCode":1000,"errorMessage":"Invalid input parameters","errorDetails":{"Password":["Password must be between 6 and 100 characters."]}},
  headers = {
    content-type = application/json; charset=utf-8,
    connection = keep-alive,
    access-control-allow-methods = GET, POST,
    access-control-allow-headers = Content-Type, Content-Encoding, X-Authentication, X-Authorization, X-PlayFabSDK, X-ReportErrorAsSuccess, X-SecretKey,
    access-control-allow-credentials = true,
    content-length = 196,
    date = Mon, 05 Dec 2016 12:46:53 GMT,
    access-control-allow-origin = *,
    x-requestid = 78fb0a0f51c741bc82c1ae35be4d1602,
    cache-control = private,
  }
}

DEBUG:SCRIPT: register error
DEBUG:SCRIPT: 
{
  error = InvalidParams,
  errorCode = 1000,
  code = 400,
  status = BadRequest,
  errorDetails = {
    Password = {
      1 = Password must be between 6 and 100 characters.,
    }
  }
  errorMessage = Invalid input parameters,
}

DEBUG:SCRIPT: Warning: Flow resulted in error	example/controller.script:56: The socket 'popup' could not be found.
DEBUG:SCRIPT: 
{
  Email = helpcare@god.ch,
  Password = helpme,
  Username = savemegod,
}

DEBUG:SCRIPT: https://6DE1.playfabapi.com//Client/AddUsernamePassword
DEBUG:SCRIPT: {"Email":"helpcare@god.ch","Password":"helpme","Username":"savemegod"}
DEBUG:SCRIPT: 
{
  status = 200,
  response = {"code":200,"status":"OK","data":{"Username":"savemegod"}},
  headers = {
    content-type = application/json; charset=utf-8,
    connection = keep-alive,
    access-control-allow-methods = GET, POST,
    access-control-allow-headers = Content-Type, Content-Encoding, X-Authentication, X-Authorization, X-PlayFabSDK, X-ReportErrorAsSuccess, X-SecretKey,
    access-control-allow-credentials = true,
    content-length = 58,
    date = Mon, 05 Dec 2016 12:47:02 GMT,
    access-control-allow-origin = *,
    x-requestid = 236f316b00944bb1a120f5f6a47ef77e,
    cache-control = private,
  }
}

DEBUG:SCRIPT: 
{
  Username = savemegod,
}

DEBUG:SCRIPT: Warning: Flow resulted in error	ludobits/m/savefile.lua:41: Could not write to the file \s4pg.1.
INFO:DLIB: SSDP: Done on address 192.168.1.2

:confused:

i already delete and got nothing inside it.

Ah, that’s better. I see that it fails to write to a file (probably to save your authentication credentials)

ludobits/m/savefile.lua:41: Could not write to the file \s4pg.1.

I’ll look into it straight away. Thanks.

I’ve fixed an issue with savefiles on Windows and also made a couple of minor tweaks to the leaderboard

1 Like
INFO:ENGINE: Defold Engine 1.2.94 (a9ec217)
INFO:ENGINE: Loading data from: build/default
INFO:ENGINE: Initialised sound device 'default'

INFO:DLIB: SSDP: Started on address 192.168.1.2
DEBUG:SCRIPT: 
{
  Email = sasas@xaffa.com,
  Password = oooooooo,
  Username = oooooooo,
}

DEBUG:SCRIPT: register error
DEBUG:SCRIPT: 
{
  error = AccountAlreadyLinked,
  errorCode = 1011,
  code = 400,
  status = BadRequest,
  errorMessage = User already linked to a different account,
}

DEBUG:SCRIPT: 
{
  Email = sasas@xaffa.cojj, <<<--- i just changing this and it freeze after clicked 
  Password = oooooooo,
  Username = oooooooo,
}

DEBUG:SCRIPT: register error
DEBUG:SCRIPT: 
{
  error = AccountAlreadyLinked,
  errorCode = 1011,
  code = 400,
  status = BadRequest,
  errorMessage = User already linked to a different account,
}

ERROR:SCRIPT: dirtylarry/dirtylarry.lua:139: No such node: email/bg
stack traceback:
	[C]: in function 'get_node'
	dirtylarry/dirtylarry.lua:139: in function 'input'
	example/menu/login/login.gui_script:32: in function <example/menu/login/login.gui_script:31>

Tweaks? how you make it?

Ok, I found one more issue in the example. Would you mind running the example again and document step by step what you are doing and when it/if it goes wrong and I’ll try to reproduce the problem here on my end as well?

1 Like

Hello, i think i found it. Maybe you see this result

warning:script: failed to return http-response

This indicates that screen navigation happened before an http callback function was invoked. I did not take into account what happened in the app after a login. A login will cause the leaderboard to refresh, but when it had refreshed navigation had already happened which messed with the callback function. I changed to use message passing to deal with that kind of callback and the error is now gone.

Please give the new version a try and let me know if you find any more problems. Again, thank you for testing and providing feedback!

Leaderboard didn’t show my username after end the game.

console output - no error

Ok, I see. But other than that things are working? I’ll look into the leaderboard issue.

Hmm, could you describe the steps you took to get the leaderboard to register your score but not show your name?

The steps im took:

  1. register new account
    2.play the game until game over or press esc
    3.leaderboard popup(showing unknown, id number and score )

And just now, i also test if the Internet connection is unstable(request time out),
and it crash

INFO:ENGINE: Defold Engine 1.2.95 (7ca47a7)
INFO:ENGINE: Loading data from: build/default
INFO:ENGINE: Initialised sound device 'default'

INFO:DLIB: SSDP: Started on address 192.168.1.2
WARNING:DLIB: SSL handshake failed (-2)
ERROR:SCRIPT: HTTP request to 'https://6DE1.playfabapi.com//Client/LoginWithCustomID' failed (http result: -1  socket result: -1000)
WARNING:SCRIPT: Failed to return http-response. Requester deleted?
INFO:DLIB: SSDP: Done on address 192.168.1.2

seem all are fine.