Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent "SoapClient::__doRequest(): SSL: Connection reset by peer" error #140

Open
jskrivseth opened this issue Oct 8, 2020 · 7 comments

Comments

@jskrivseth
Copy link

Running on PHP 7.3, using "microsoft/bingads": "v0.12.13.6" we hit this error constantly, at random, when doing a SearchAccounts request

public static function AuthData(): AuthorizationData
    {
         ...
    }

 public static function Accounts($ids = null)
    {
        $config = self::config();
        $pageInfo = new Paging();
        $pageInfo->Index = 0;    // The first page
        $pageInfo->Size = 500;   // The first 100 accounts for this page of results

        $predicate = new Predicate();
        $predicate->Field = 'UserId';
        $predicate->Operator = PredicateOperator::Equals;
        $predicate->Value = $config['userId'];

        $request = new SearchAccountsRequest();
        $request->Ordering = null;
        $request->PageInfo = $pageInfo;
        $request->Predicates = [$predicate];

        if ($ids !== null) {
            $predicate = new Predicate();
            $predicate->Field = 'AccountNumber';
            $predicate->Operator = PredicateOperator::In;
            $predicate->Value = implode(',', $ids);
            $request->Predicates[] = $predicate;
        }
 
       $client = new ServiceClient(ServiceClientType::CustomerManagementVersion13, self::AuthData(), ApiEnvironment::Production);
        return $client->GetService()->SearchAccounts($request)->Accounts;
    }

I would say this works a little more than 50% of the time. The rest of the time, we receive SoapClient::__doRequest(): SSL: Connection reset by peer

I'm guessing it's related to TLS version, but that's a shot in the dark

@jskrivseth jskrivseth changed the title Random "SoapClient::__doRequest(): SSL: Connection reset by peer" Intermittent "SoapClient::__doRequest(): SSL: Connection reset by peer" error Oct 8, 2020
@eric-urban
Copy link
Contributor

@voodoodrul I'm not able to reproduce this issue currently. It might have been a temporary service issue, although I didn't hear of anything systemic. If you are still observing the error please let us know. BTW I suggest please upgrade to the latest SDK, although since you are using v13 anyways this is probably unrelated to the issue you observed.

@jskrivseth
Copy link
Author

jskrivseth commented Oct 9, 2020

@eric-urban This has been a problem for over a year and a half and continues to be a problem today. We've simply been wrapping all API calls in a retry middleware to eventually become successful. It may be related to rate limiting, or clustering of requests around the same time, but I have seen it happen when only one request from a given IP hits the endpoint at a given time.

@jskrivseth
Copy link
Author

image
You can see counts of how often this has happened for us in the last 30 days

@eric-urban
Copy link
Contributor

@voodoodrul

You mentioned it might be related to TLS. Please also note we had communicated the TLS change 2.5 years ago e.g., here:

https://docs.microsoft.com/en-us/archive/blogs/bing_ads_api/mandatory-upgrade-required-to-tls1-2

https://social.msdn.microsoft.com/Forums/en-US/7bc321a6-c8d3-4440-b9f5-603242a06f81/preparing-for-the-mandatory-use-of-tls-12-in-bing-ads?forum=BingAds

I suggest please double check TLS requirements.

@jskrivseth
Copy link
Author

jskrivseth commented Oct 9, 2020

@eric-urban We're using the default settings of the SDK so it should be negotiating TLS 1.2 automatically. I'm not sure off-hand how to verify this. We are using OpenSSL 1.1.1 11 Sep 2018 and appears to support TLS 1.2. Even so, the fact that it's intermittent is the weird part..

@jskrivseth
Copy link
Author

@eric-urban Do you have any further investigation or guidance on this? Our solution at the moment is to wrap all calls to the Bing API in a huge number of retries, and eventually it becomes successful. It seems to be related to load balancing and quotas, since we hit the API fairly hard around the same time for multiple accounts. Do you know what the quotas are? We'll need to come up with a distributed throttle mechanism to slow down all the workers to stay under the threshold, but that's the only working theory I have right now.

One of the calls we don't have wrapped in a retry is pulling reports, which throws:

SoapFault exception: [s:Server] Invalid client data. Check the SOAP fault details for more information. TrackingId: 91320240-c27a-4302-b0ff-6dee16b50c2a

I'll add the SoapFault details as soon as I capture them

@eric-urban
Copy link
Contributor

@voodoodrul I suggest troubleshooting the invalid client data separate from the SSL error. Regarding invalid client data yes please share the SOAP request, response, and timestamp if available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants