xero-php icon indicating copy to clipboard operation
xero-php copied to clipboard

Gateway Time-out - getAccessToken

Open olimortimer opened this issue 1 year ago • 5 comments

I regularly receive timeouts from Xero when getting an access token, but can't see how to extend the timeout period - old issues mention a config file, but that doesn't seem to exist any now?

        Calcinai\OAuth2\Client\Provider\Exception\XeroProviderException
        Gateway Time-out
        $accessToken = $provider->getAccessToken('client_credentials', [
            'scope' => $scope,
        ]);

Around the same time as the above, I also receive the following;

        GuzzleHttp \ Exception \ ConnectException
        cURL error 35: OpenSSL SSL_connect: Connection reset by peer in connection to identity.xero.com:443 (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://identity.xero.com/connect/token

olimortimer avatar Dec 20 '23 10:12 olimortimer

This may or may not help, but have you looked at the constructor of the AbstractProvider? You should be able to pass timeout as an option in there.

calcinai avatar Dec 20 '23 21:12 calcinai

Thank you. I've taken a look, but not quite sure how to pass through a new timeout value.

olimortimer avatar Dec 21 '23 11:12 olimortimer

By the looks, it's as simple as adding a timeout key to the constructor of the OAuth provider

calcinai avatar Jan 03 '24 20:01 calcinai

Would you mind providing an example on how to do that with calcinai/xero-php please?

olimortimer avatar Jan 04 '24 13:01 olimortimer

Hi @olimortimer it’s not actually part of this library. The link I posted above was to the league/oauth2 library, which is extended and used here. I’m 100% sure on the suggestion, as it was based on skimming the code in that library.

I’d recommend taking a proper look there to see which options/config is allowed to be passed in.

calcinai avatar Jan 04 '24 18:01 calcinai