question

hendawi avatar image
hendawi asked

The underlying connection was closed: An unexpected error occurred on a receive.

hello,

i got this error message "The underlying connection was closed: An unexpected error occurred on a receive." when getting leaderboard data using dotnet sdk , the error happened suddenly on server (was working before ) and working fine on local machine

this is the code :

private async void GetLeaderboardServerSide()

{

PlayFabSettings.TitleId = System.Configuration.ConfigurationManager.AppSettings["playfabTitleID"]; PlayFabSettings.DeveloperSecretKey= System.Configuration.ConfigurationManager.AppSettings["Secret_Key"]; GetLeaderboardRequest request = new GetLeaderboardRequest()

{ StartPosition = 0, MaxResultsCount = 10, StatisticName = "Total Happiness", ProfileConstraints = new PlayerProfileViewConstraints()

{ ShowContactEmailAddresses = true, ShowDisplayName = true, ShowAvatarUrl = true }, };

PlayFabResult<GetLeaderboardResult> x = await PlayFabServerAPI.GetLeaderboardAsync(request);

var apiError = x.Error;

var apiResult = x.Result;

if (apiError != null) { _msg = apiError.ErrorMessage; }

else if (apiResult != null)

{ lbList = apiResult.Leaderboard; } }

10 |1200

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

JayZuo avatar image
JayZuo answered

Your code looks good to me and as you've said "the error happened suddenly on server (was working before)", so there may be some network traffic issue between your server and PlayFab server. If this issue only happens accidentally, then you can do a retry. But if it happens a lot of times, I'd suggest you check the network traffic with some tools like Fiddler or Wireshark to see what's the problem underlay.

11 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.

hendawi avatar image hendawi commented ·

i tried to call leaderboard through post man from server and it works fine

i made POST call to https://2A0B.playfabapi.com/Server/GetLeaderboard , with header parameters and body parameters

also tried fetch method from chrome console on server and leaderboard data returned !!

So it's not traffic issue , it's related to sdk itself (PlayFabAllSDK installed v 1.0.374)

0 Likes 0 ·
JayZuo avatar image JayZuo ♦ hendawi commented ·

The latest version is 1.52.190610 now. Could you please try with the latest one to see if there is any issue?

0 Likes 0 ·
hendawi avatar image hendawi JayZuo ♦ commented ·

update to latest version and issue still as is !

0 Likes 0 ·
hendawi avatar image hendawi commented ·

update to latest version and issue still as is !

0 Likes 0 ·
JayZuo avatar image JayZuo ♦ hendawi commented ·

I can't reproduce this issue with your code and latest SDK. Could you get us a Fiddler capture, so that we can see the specifics of the network behavior? Also, what is your Title ID?

0 Likes 0 ·
hendawi avatar image hendawi JayZuo ♦ commented ·

nothing appear in fiddler since SDK not send request i guess , also post call to api from postman and chrome console working fine. my title id 2A0B

0 Likes 0 ·
Show more comments
Show more comments
JayZuo avatar image JayZuo ♦ hendawi commented ·

There is no change to PlayFab API security protocol. We have used TLS 1.2 for a long time.

0 Likes 0 ·
hendawi avatar image
hendawi answered

It looks that windows update disabled SecurityProtocolType Tls12 , i added the below line to my helper class constructor and all PlayFab related methods finally works

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

thanks @Jay Zuo for your support

i'm still trying to figure out the reason behind that sudden change on server.


playfab.png (29.4 KiB)
10 |1200

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

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.