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

Fatal error: Uncaught Mailgun\Connection\Exceptions\GenericHTTPError: An HTTP Error has occurred! Check your network connection and try again

Open rafmud opened this issue 9 years ago • 9 comments

Hi, I have integrated mailgun in my php project and it was working fine. I was using validate email function and it was all set but now its giving me this error and I am frustrated solving this but don't have a clue that what's wrong with this as all the credentials are same and every line of code is same but this is not working . I even tried new installs as well and new server too but nothing. send mail function is working fine but not validate email. Help me please, have to deliver this asap

rafmud avatar Oct 25 '17 17:10 rafmud

An HTTP Error has occurred! Check your network connection and try again.

This happens for me as well. Perhaps once or twice a month and it kills my daily reports.

dustingraham avatar Nov 21 '17 18:11 dustingraham

May I ask what's the error message thrown by that error, so someone can investigate it?

Also, maybe you can add a try ... catch ... to process the error in case of failure

DavidGarciaCat avatar Nov 21 '17 20:11 DavidGarciaCat

Hi , Thank you for your replies but it started working after a while . I don't know what triggered what but it finally worked.

rafmud avatar Nov 21 '17 20:11 rafmud

  catch (Exception $e)
    {
        echo 'Error: '.$e->getMessage().PHP_EOL;
    }

Echos out...

Error: An HTTP Error has occurred! Check your network connection and try again.

It is only intermittent. I have a script that runs daily, and once or twice a month it dies on this error. I suspect it's a temporary response failure from mailgun's API.

Feel free to close this, I just wanted to mention that I also had the problem.

dustingraham avatar Nov 21 '17 20:11 dustingraham

It looks like an API failure, indeed.

Did you try the same case I said above, something like this?

try {
    // call
} catch (GenericHTTPError $exception) {
    try {
        // call
    } catch (GenericHTTPError $exception) {
        throw $exception;
    }
}

Maybe in this case if there is a downtime the 2nd call will work. I have realised about this issue working with another API that returned me DNS or Timeout errors, so when I called the API endpoint again then it worked.

Not the best / clean / nice solution, but it worked...

DavidGarciaCat avatar Nov 21 '17 20:11 DavidGarciaCat

Yea, I've done that before, and I'll try adding it in. Usually fixes another 90% of the issues when doing that, and then some times it is just flat down. :) I'll try on my own time. Sounds like the original issue is resolved though.

dustingraham avatar Nov 21 '17 20:11 dustingraham

In my case it does not solve the problem it is always the same error, https://i.imgur.com/MIJmddw.png

$result = $this->pubKey->get("address/validate", array('address' => $email));
return $result->http_response_body->is_valid;

flesoft avatar Feb 28 '18 22:02 flesoft

What is the root cause of this issue, as services that depend on the address validation API functioning as described are severely impacted?

ogomandco avatar Jul 23 '18 15:07 ogomandco

I get the same thing a fair bit too - for me though it looks like the attachments I was trying to include were too big and it was timing out on part of the transfer.

jesse1981 avatar Mar 18 '19 22:03 jesse1981