jcrv
jcrv

Reputation: 695

Google App Engine requests hanging timeout

I have an application in production for couple of years in Google App Engine (GAP). In a given entry point of my application I get data from a 3rd party API using requests as such:

@app.route('/example')
def example():
    response = requests.get(url, params=PARAMS, headers=HEADERS)

Studently (2 days ago), this peace of code stopped working. Basically, what happens is that the request is hanging, and after 30sec, the worker dies with the error message:

upstream prematurely closed connection while reading response header from upstream, client...

Nonetheless, the API responds immediately when executing the code in my local computer. The same exact behavior is detected when using curl in shell.

Any idea what might causing this? Or to debug it? Can this be related with some DNS problem? I don't even know if the problem is related with the API or is GAE that somehow is blocking the request.

Thanks in advance!

Upvotes: 0

Views: 364

Answers (1)

minou
minou

Reputation: 16563

I have some theories:

(1) Rate Limiting -- If you are doing this API call a lot, they may be blocking your IP address.

(2) 1st Gen GAE headers -- 1st gen GAE sends special headers with every request. This makes it obvious that a computer is initiating the request and not a person. It is possible that the third party blocks requests with these headers.

(3) Blocking Cloud IPs -- Google publishes a full list of its IP addresses and the third party may be blocking all of them.

Given that it works on your own computer with curl, I suspect (1) is the answer. If they would do (2) or (3) then they would likely also block curl.

Upvotes: 2

Related Questions