Question

I am trying to have a persistent connection to a third party using app engine. Specifically I am hooking into a real time bidding environment where I need to respond in under 100ms, and thus a persistent connection greatly accelerates the process.

In order to do this I am attempting to use urllib3 (if there is a better way please tell me) When my request handler's post method gets called, I want to write back out to the calling url keeping the connection open. I understand how to open a request with urllib3, but how do I persist the connection that was created when the post method on the handler was called.

At the moment I am trying:

http = urllib3.PoolManager()
r = http.request('POST', self.request.url, fields={"foo":"bar"})

But I fear I am opening an entirely new connection doing this.

Thanks, Sam

Was it helpful?

Solution

There is no way to achieve persistent connection to a server with AppEngine, by design every request on the app engine closes after finish sending.

The URL Fetch service does not support persistent HTTP connections. When the app accesses response data using the URLConnection object, App Engine calls the URL Fetch service to complete the request. After the response data has been accessed, the request data cannot be modified.

The app cannot set explicit connection timeouts for the request.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top