Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppEnginePlatformWarning: urllib3 is using URLFetch on Google App Engine sandbox instead of sockets

I'm getting this error on app engine using flask to make a Slack bot. It happens whenever I send a POST request from Slackbot.

Unfortunately, the url provided in the error is a dead link. How do I go about using sockets instead of URLFetch?

/base/data/home/apps/[REDACTED]/lib/requests/packages/urllib3/contrib/appengine.py:115: AppEnginePlatformWarning: urllib3 is using URLFetch on Google App Engine sandbox instead of sockets. To use sockets directly instead of URLFetch see https://urllib3.readthedocs.io/en/latest/contrib.html.

like image 920
ttremblay Avatar asked Dec 18 '22 10:12

ttremblay


2 Answers

As detailed on Google's Sockets documentation, sockets can be used by setting the GAE_USE_SOCKETS_HTTPLIB environment variable. This feature seems to be available only on paid apps, and impacts billing.

Though the error you posted gets logged as an Error in App Engine, this thread suggests (see reply #8) that the error is actually meant as a warning, which the text "AppEnginePlatformWarning" seems to suggest anyway.

The comment block on the source page for appengine.py is also instructive.

You didn't post any information about your implementation, but on Google App Engine Standard edition, using URLFetch via the AppEngineManager should be just fine, though you will get the error.

like image 122
HondaGuy Avatar answered Dec 25 '22 23:12

HondaGuy


You can use the following to silence this:

import warnings
import urllib3.contrib.appengine

warnings.filterwarnings('ignore', r'urllib3 is using URLFetch', urllib3.contrib.appengine.AppEnginePlatformWarning)
like image 45
r3m0t Avatar answered Dec 25 '22 23:12

r3m0t