fbradyirl / webex_bot

Python package for a Webex Bot based on websockets.
MIT License
68 stars 44 forks source link

Websocket connection through Proxy Server #35

Closed Sly-Turtle closed 1 year ago

Sly-Turtle commented 1 year ago

Is there an existing way to configure the webex_bot to access webexapis.com through a proxy server? The webexteamssdk module has this functionality but I have not seen anything similar in webex_bot:

proxy = {'https': 'http://:'} api = WebexTeamsAPI(access_token=WEBEX_TEAMS_ACCESS_TOKEN,proxies=proxy)

import os
import Token

from webex_bot.webex_bot import WebexBot

webex_token = Token.BOT_WEBEX_TEAMS_ACCESS_TOKEN

bot=WebexBot(webex_token,approved_domains=['domainhere.com'])
bot.run()

Without a proxy connection, I get the following error when I execute bot.run().

"ConnectionError: HTTPSConnectionPool(host='webexapis.com', port=443): Max retries exceeded with url: /v1/people/me (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002570BB6FB50>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))"

gconklin commented 1 year ago

I believe this is not possible currently due to webex_bot using the "websockets" library which does not support a proxy.

https://websockets.readthedocs.io/en/stable/reference/limitations.html?highlight=proxy Lengthy discussion here: https://github.com/aaugustin/websockets/issues/364

fbradyirl commented 1 year ago

Correct. If you have a proxy, I think websockets is not the way you want to go.

nomadalex commented 1 year ago

@Sly-Turtle you can use websocket-client library instead. To use websocket-client with asyncio, you can look at wsapi.py as a reference.