Cannot connect to Moku due to workplace proxy settings

Moku model: Moku:Pro
Operating system: macOS
Software version: 2.5.1

Bug or support request description:

At my workplace, we have default proxies that must be set on our devices. This becomes an issue when, for example, I am connecting to the Moku via USB-C and the Python API. When a request is sent, it uses the default proxies, and I’ll receive a 503 error when trying to connect the Moku.

My solution has been to download the source code for the Moku Python API, and recompile it with a single change to the file:

class RequestSession:
    json_headers = {'Content-type': 'application/json'}
    sk_name = "Moku-Client-Key"  # session key name

    def __init__(self, ip, connect_timeout, read_timeout):
        self.ip_address = ip
        self.connect_timeout = connect_timeout
        self.read_timeout = read_timeout
        self.session_key = None = Session() = False

where I have added the last line to the initialization of the RequestSession class in the moku Python package. With this addition, requests.Session does not load the default proxies that are set on my mac, but just keeps the proxies blank, and I can successfully communicate/run the Moku from the Python API. The reason this works is that it skips these lines in requests.Session: requests/ at main · psf/requests · GitHub, which otherwise load the default proxies from the system configuration files.

I was wondering if this should/could be added to the moku package itself? Alternatively, could we add a way of setting specific proxies (in my case, removing the default proxies from my device)? I would prefer to avoid using a customized version of the moku Python API for my purposes.



Hey Sam, this is a neat workaround and thanks for sharing!

We are actually planning to add the exact feature you are talking about in our end of January 2023 release which will allow you to configure multiple personal proxies using our APIs! I will be sure to provide more details in this thread once they are made available.

Awesome, that sounds great! Looking forward to that release, thanks!

Following up on this post, you now have the option of making your own proxies without having to edit the source code! You can now configure request session attributes, for example custom proxy or authentication parameters. Please see ‘Access requests.session’ section of the API documentation for more information.