1
votes

I am running ngrok to forward webhooks at my local vagrant running ubuntu and apache (it is a php laravel application). I am getting intermittent bad gateway errors.

What is strange is that the inspector on http://127.0.0.1:4040/ is showing 200's

The third party system that is firing the webhooks is returning the raw html as

<html>
    <body>
        <h1>502 Bad Gateway</h1>
The server returned an invalid or incomplete response.

    </body>
</html>

Because it works sometimes I don't think there is a problem with the setup. Any suggests would be helpful. Right now I just hit it again and again until it is successful.

One thing is that the local dev is slow,

For example from the ngrok inspector.

GET /inbound/webhook 200 OK 3.44s

I noticed that the slower response are more likely to throw a 502.

Anyone know how to fix this problem?

1
Given that's an nginx error page and you're running Apache, this seems like it might be a problem with ngrok itself. Might be worth opening an issue on the ngrok GitHub project.philnash
There is a 15 second request timeout so it should not be a network performance issuejcpennypincher

1 Answers

3
votes

So actually what is happening in your case is, the request is reaching your server and it responds after the request has been timed out. Hence Twilio responds with 502 after a timeout. But your server is sending a correct response (Request is not capable of taking your response due to delay).

Kindly make sure your server's responding time is faster! That will fix this.