bgmulinari / B1SLayer

A lightweight SAP Business One Service Layer client for .NET
MIT License
122 stars 42 forks source link

Call timed out: POST https://xxx.xxx.net:50000/b1s/v1/Login With Initial call #72

Open johandantuma opened 1 month ago

johandantuma commented 1 month ago

I'm experiencing a stang issue with regards to the login part of the B1Slayer. When running the first instance of a API BO of B1Slayer the connection times out.

When retrying it if work without any problems. When the connection timers out after 30 of if i recompile my C# project and rerun it also times out.

bgmulinari commented 1 month ago

Hi @johandantuma.

Can you provide more information regarding your scenario and maybe provide a code snippet that reproduces your issue?

Do you observe the same issue when logging in through Postman, for instance?

johandantuma commented 1 month ago

Hi Bruno

The issue doesn’t arise when using postman

The connection service layer

public sealed  class ServiceLayer
{

    private static readonly SLConnection _serviceLayer = new SLConnection(
         https://nuvo.seidorcloud.net:50000/b1s/v1/,
        "UAT_TRAININGDB", "Rcsys", ***@***.***!");

    static ServiceLayer() { }

    private ServiceLayer() { }

    public static SLConnection Connection => _serviceLayer;

}

One of my calls to the API

var v = await ServiceLayer.Connection

                    .Request("$crossjoin(BusinessPartners,PaymentTermsTypes)")
                    .WithTimeout(240)
                    .Expand("BusinessPartners($select=CardCode,CardName,Notes),PaymentTermsTypes($select=CreditLimit,PaymentTermsGroupName)")
                    .Filter("BusinessPartners/PayTermsGrpCode eq PaymentTermsTypes/GroupNumber and CardType eq 'C'")
                    .WithPageSize(0)

                    .GetStringAsync();

From: Bruno Mulinari @.> Sent: Wednesday, May 8, 2024 4:26 PM To: bgmulinari/B1SLayer @.> Cc: Johan Dantuma @.>; Mention @.> Subject: Re: [bgmulinari/B1SLayer] Call timed out: POST https://xxx.xxx.net:50000/b1s/v1/Login With Initial call (Issue #72)

Hi @johandantumahttps://github.com/johandantuma.

Can you provide more information regarding your scenario and maybe provide a code snippet that reproduces your issue?

Do you observe the same issue when logging in through Postman, for instance?

— Reply to this email directly, view it on GitHubhttps://github.com/bgmulinari/B1SLayer/issues/72#issuecomment-2100711839, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOJC3TPAX37B5SWYTG3V3LDZBIYVZAVCNFSM6AAAAABHMTQOKWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBQG4YTCOBTHE. You are receiving this because you were mentioned.Message ID: @.**@.>>

bgmulinari commented 1 month ago

@johandantuma, I see that you are setting the page size to zero, which means you are trying to obtain all records in the database in a single request. Depending on the number of records to retrieve, this could take a long time and therefore could be te reason for the timeout you are experiencing.

If you wish to retrieve all records, I recommend using the GetAllAsync request method. This will loop through all pages for you until all records are retrieved. For this you will need to define a model class for the object, as GetAllAsync returns a list of said object type.

johandantuma commented 1 month ago

Hi Bruno

I see what you’re getting at but as a test I’ve just done a basic Login using

@.***

And I’m still getting a timeout

@.***

From: Bruno Mulinari @.> Sent: Wednesday, May 8, 2024 4:54 PM To: bgmulinari/B1SLayer @.> Cc: Johan Dantuma @.>; Mention @.> Subject: Re: [bgmulinari/B1SLayer] Call timed out: POST https://xxx.xxx.net:50000/b1s/v1/Login With Initial call (Issue #72)

@johandantumahttps://github.com/johandantuma, I see that you are setting the page size to zero, which means you are trying to obtain all records in the database in a single request. Depending on the number of records to retrieve, this could take a long time and therefore could be te reason for the timeout you are experiencing.

If you wish to retrieve all records, I recommend using the GetAllAsync request method. This will loop through all pages for you until all records are retrieved. For this you will need to define a model class for the object, as GetAllAsync returns a list of said object type.

— Reply to this email directly, view it on GitHubhttps://github.com/bgmulinari/B1SLayer/issues/72#issuecomment-2100774566, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOJC3TNC2YEXTXNOZX6GRHTZBI377AVCNFSM6AAAAABHMTQOKWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBQG43TINJWGY. You are receiving this because you were mentioned.Message ID: @.**@.>>