I am using urlfetch function for google mechanism for remote login to another web service. Everything works fine during development, but when I move on to production, the login procedure fails. Do you have any suggestions on how to debug product URL retrieval?
I use cookies and other headers in my selection of URLs (I manually set cookies in the header). One cookie is a session cookie.
No errors or exceptions. When you create a message to enter the URL command, a session cookie is returned, but when you request a page using session cookies, they are ignored and the login information is requested again. When developing after receiving session cookies, you can access the internal pages just fine. I thought the problem was with cookies being saved, but they look right as the requests are almost identical.
This is what I call it:
fetchresp = urlfetch.fetch(url=req.get_full_url(), payload=req.get_data(), method=method, headers=all_headers, allow_truncated=False, follow_redirects=False, deadline=10 )
Here are some insights regarding the problem:
- The distributed nature of the google url fetch implementation is a mess.
- In production, headers are sent in a different order than in development, possibly confusing the server.
- Some google servers are blacklisted by the destination server.
Here are some hypotheses that I excluded:
- Google caching is too aggressive. But I still get the problem after disabling the cache using the Cache-Control: no-store header.
- Google urlfetch is too fast for the destination server. But I still get the problem after inserting delays between calls.
- Google adds some data to the User-Agent header. But I added this header for development, and I had no problem.
What other differences exist between fetching the product URL and fetching the development URL? Do you have any ideas for debugging this?
UPDATE 2
(The first update was included above) I donβt know if it was something I did (maybe by adding delays or disabling the caches mentioned above), but now the working environment works in about 50% of cases. It definitely looks like a race condition. Unfortunately, I have no idea if there is a problem in my code, google codec or destination server.
source share