Search code examples
phpsoap

MS_MAX_CONCURRENT_REQ - VIES VAT Validation


I want to confirm multiple addresses by using https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl.

For some reason, I keep getting the MS_MAX_CONCURRENT_REQ error. I understand the meaning of the error, but I can't understand why it keeps occurring so randomly. I have a sleep of 15 seconds after each call. I could filter out so far that the error occurs mainly with German VAT ID's.

How can I minimize this error without increasing the sleep time?

This is my current SOAPClient Setup.

        $client = new SoapClient('https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl', ['trace' => false,'keep_alive' => false]);
        $result = $client->checkVatApprox([
            'countryCode' => $countryCode,
            'vatNumber' => $vatNumber,
            'traderName' => $traderName,
            'traderStreet' => $traderStreet,
            'traderPostcode' => $traderPostcode,
            'traderCity' => $traderCity,
            'requesterCountryCode' => $requesterCountryCode,
            'requesterVatNumber' => $requesterVatNumber
        ]);

Solution

  • As you can find in the documentation of the WSDL of this service:

    • MS_MAX_CONCURRENT_REQ: Your Request for VAT validation has not been processed; the maximum number of concurrent requests for this Member State has been reached. Please re-submit your request later or contact [email protected] for further information": Your request cannot be processed due to high traffic towards the Member State you are trying to reach. Please try again later.

    There is nothing you can do about it yourself except periodically trying again until it succeeds. Make sure to use a friendly back-off strategy, such as doubling the sleep time between each request in case of failure (also known as "exponential backoff").