'mitmproxy script can't connect to cosmos db

I am using proxy server using mitmproxy in Python. It worked great, but when I tried connecting to Cosmos Client using the following code:

import azure.cosmos.cosmos_client as cosmos_client
client = cosmos_client.CosmosClient(cosmos_uri, key)

The script stuck and can't continue. I am running the proxy using the command: mitmweb -s python_code.py.

I tried changing the location of when the connection is done (in running hook and in done hook), but it doesn't seem to change anything:

class ChangeHTTPCode:
    def running(self):
        client = cosmos_client.CosmosClient(cosmos_uri, key)

addons = [ChangeHTTPCode()]

Do you know why this connection might do that?

It's worth saying that when I ran this code outside the script (as a standalone script) it worked (with and without using the proxy).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source