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 session.py
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
self.rs = Session()
self.rs.trust_env = 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/sessions.py 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.
Thanks!
Sam