admin管理员组文章数量:1336187
My goal is to configure a proxy with authorization for an Android emulator (used with Appium) launched from command line.
I tried configuring the Android emulator directly with a proxy via this command:
emulator -avd <device> -http-proxy 'http://<user>:<password>@<host>:<port>'
Or setting in Android Studio settings
But I face the ERR_CONNECTION_REFUSED
issue for HTTPS traffic.
Most solutions on internet handle this without the proxy auth. So a solution is to remove authorization from proxy by setting up local upstream proxy to the actual proxy with auth.
In Node.js, I achieved this with the proxy-chain
library using the following code:
const { anonymizeProxy } = require('proxy-chain');
(async () => {
const proxy = 'http://<user>:<password>@<host>:<port>';
const anonymizedProxy = await anonymizeProxy(proxy);
console.log(anonymizedProxy);
})();
This setup worked perfectly, handling HTTP and HTTPS traffic without issues. I tried to replicate this behavior in Python using pproxy
library with the following code:
import asyncio
import pproxy
async def main():
local_server = ':1234'
upstream_proxy = 'http://<user>:<password>@<host>:<port>'
server = pproxy.Server(local_server)
remote = pproxy.Connection(upstream_proxy)
args = {'rserver': [remote]}
await server.start_server(args)
await asyncio.Event().wait()
asyncio.run(main())
It works for HTTPS as system proxy inside my browser, but for emulator I still see ERR_CONNECTION_REFUSED
error for HTTPS requests.
I do not need any traffic inspection just forwarding to the real proxy.
Is it possible to achieve this in Python? Are there libraries similar to proxy-chain for Python? Or is there a way to properly configure the Android emulator to use an authenticated proxy? Any insights would be appreciated!
本文标签: Handling HTTPS Proxy Authentication in Android Emulator with PythonStack Overflow
版权声明:本文标题:Handling HTTPS Proxy Authentication in Android Emulator with Python - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742398534a2467412.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论