[Duplicate] Error KeyError: 'automation'
I have exactly the same problem https://github.com/DedInc/pyanty/issues/25
My code is something like this:
def find_profile(profiles, username=""):
if profiles:
for profile in profiles['data']:
if username in profile['name']:
return profile
return False
api = DolphinAPI(api_key=config.anty_api_key)
api_profiles = api.get_profiles()
fingerprint = api.generate_fingerprint(platform='windows', browser_version=STABLE_CHROME_VERSION - 1)
profile = api.get_profile(profile['id'])
api.edit_profile(profile['id'], {'proxy':{ 'host': '127.0.0.1','port': 40000, 'type': 'socks5'}})
response = api.edit_profile(profile['id'], {'webrtc': {'mode': 'manual','ipAddress': '175.29.132.167'}})
print(response)
# Init WebDriver (Chrome) and run profile
profile = dolphin.run_profile(profile['id'])
print(f"RUN PROFILE DATA:\n\n{response}\n\n")
try:
port = profile['automation']['port']
print(f"[DEBUG] profile['automation']['port'] = {profile['automation']['port']}")
except:
print(f"[ERROR] automation->port not found or already in use")
print(f"Debug data: {profile}")
# if maybe it in use? try to next port
port = profile['automation']['port']+1
arguments = ['useAutomationExtension=False']
driver = dolphin.get_driver(port=port, arguments=None)
#.... next code with profile.......
#after work with profile
dolphin.close_profile(profile['id'])
driver.quit()
I noticed that the first time, chromedriver starts fine, and the browser too. But when I restart, chromedriver does not start.
PS: If I go to Dolphin, select this profile to edit, I get the following response:
{"request":{"url":"https://dolphin-anty-api.com/proxy/486259839"},"response":{"status":404,"data":{"success":false}}}
Is there a solution for it?
It would seem that before the Dolphin update, everything worked fine!
In the Dolphin Anty logs along the path: %appdata%\dolphin_anty\logs
The following information is displayed: (and nothing else)
2025-04-20T16:49:03.170Z24175838587100ns 58867712:52800336 20515000:43580000 ❌ ProxyManager | Proxy check timed out after 17000ms Error: No valid response from any host
at m (C:\Users\Professional\AppData\Roaming\dolphin_anty\local-api\7d1b92245a5a89b46fb5b3ea1f3ff291\dist\main.js:1372:2276)
at async Zut.checkWithRetriesAndTimeout (C:\Users\Professional\AppData\Roaming\dolphin_anty\local-api\7d1b92245a5a89b46fb5b3ea1f3ff291\dist\main.js:1372:2569)
at async gct._initConnectionInfo (C:\Users\Professional\AppData\Roaming\dolphin_anty\local-api\7d1b92245a5a89b46fb5b3ea1f3ff291\dist\main.js:1376:31941)
at async gct.startNew (C:\Users\Professional\AppData\Roaming\dolphin_anty\local-api\7d1b92245a5a89b46fb5b3ea1f3ff291\dist\main.js:1373:6688)
at async e_n.exports (C:\Users\Professional\AppData\Roaming\dolphin_anty\local-api\7d1b92245a5a89b46fb5b3ea1f3ff291\dist\main.js:1376:51088)
2025-04-20T16:49:03.170Z24175838643900ns 58867712:52806444 23969000:25623000 🟡 _initConnectionInfo | Необычная ошибка при проверке соединения с прокси {e:'Error:Novalidresponsefromanyhost',proxyString:'socks5://127.0.0.1:40000',i:1,browserProfileId:599057864}
2025-04-20T16:49:03.170Z24175838688100ns 58867712:52811572 20515000:43580000 ℹ️ _initConnectionInfo | Получаю данные соединения :: Прокси socks5://127.0.0.1:40000 :: Попытка 2 :: Ошибка проверки соединения с прокси {e:Error:Novalidresponsefromanyhostatm(C:\Users\Professional\AppData\Roaming\dolphin_anty\local-api\7d1b92245a5a89b46fb5b3ea1f3ff291\dist\main.js:1372:2276)atasyncZut.checkWithRetriesAndTimeout(C:\Users\Professional\AppData\Roaming\dolphin_anty\local-api\7d1b92245a5a89b46fb5b3ea1f3ff291\dist\main.js:1372:2569)atasyncgct._initConnectionInfo(C:\Users\Professional\AppData\Roaming\dolphin_anty\local-api\7d1b92245a5a89b46fb5b3ea1f3ff291\dist\main.js:1376:31941)atasyncgct.startNew(C:\Users\Professional\AppData\Roaming\dolphin_anty\local-api\7d1b92245a5a89b46fb5b3ea1f3ff291\dist\main.js:1373:6688)atasynce_n.exports(C:\Users\Professional\AppData\Roaming\dolphin_anty\local-api\7d1b92245a5a89b46fb5b3ea1f3ff291\dist\main.js:1376:51088),browserProfileId:599057864}
2025-04-20T16:49:03.170Z24175838729600ns 58867712:52821212 23969000:25623000 ℹ️ _initConnectionInfo | Получаю данные соединения :: Прокси socks5://127.0.0.1:40000 :: Попытка 3 {browserProfileId:599057864}
2025-04-20T16:49:08.047Z24180715930400ns 58867712:53079044 20515000:43580000 ❌ Ошибка проверки прокси | Error: error sending request for url (https://geo.anty-proxy-checker.com/ip-info)
The problem occurs when I use a proxy (local with a forwarded port to an external socks5):
api.edit_profile(profile['id'], {'proxy':{ 'host': '127.0.0.1','port': 40000, 'type': 'socks5'}})
If I try to use an external host, there are no problems.
I am still getting this problem. It seems that the profile closing method is not working correctly, causing the browser window not to close properly.
Dolphin Anty checks proxies on its own server, so a local proxy won't work for you unless you use an open IP address of your computer instead of 127.0.0.1. You need to set everything up so that Dolphin Anty can connect to your proxy from outside, otherwise it won't work.