Home > OS >  Communication between Microservices in Google App Engine
Communication between Microservices in Google App Engine

Time:01-30

I have currently 5 different services in Google App Engine all of them are in FastAPI Python standard environment. When a service gets called they call an authorization service and continue if permissions are valid. Im using firewall rule to disable all incoming requests but allow my computer. When using the firewall rule I cannot call the other service because it return Access Forbidden. I then found something about the requests in Python in GAE that you have to use Google's URLfetch to make calls to other services. But when I use the monkeypatch() function from requests_toolbelt.adapters.appengine I recieve an error in App Engine

  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/requests_toolbelt/adapters/appengine.py", line 121, in __init__
    self.appengine_manager = gaecontrib.AppEngineManager(
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/contrib/appengine.py", line 107, in __init__
    raise AppEnginePlatformError(
urllib3.contrib.appengine.AppEnginePlatformError: URLFetch is not available in this environment.

The main reason to restrict the API's is that nobody is able to read the docs from the services.

CodePudding user response:

As mentioned in this docThe Python 3 runtime doesn't need an intermediary service to handle outbound requests. If you want to migrate away from using URL Fetch APIs but still need similar functionality, you should migrate those requests to use a standard Python library such as the requests library.

As discussed in this thread seems you are also facing the similar issue

The presence of requests_toolbelt dependency in the project was the problem: it somehow forced the requests library to use urllib3, which requires URLFetch to be present, otherwise it raises an AppEnginePlatformError. As suggested in the app engine docs monkey-patching Requests with requests_toolbelt forces the former to use URLFetch, which is no longer supported by GAE in a Python 3 runtime.

You may resolve this by removing requests_toolbelt from requirements.txt file

You can also have a look at this stackoverflow thread

  • Related