Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket connection through Proxy Server #35

Closed
Sly-Turtle opened this issue Sep 1, 2022 · 3 comments
Closed

Websocket connection through Proxy Server #35

Sly-Turtle opened this issue Sep 1, 2022 · 3 comments

Comments

@Sly-Turtle
Copy link

  • Webex Bot version: 0.3.3
  • Python version: 3.9
  • Operating System: Windows

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://<proxy_ip>:<proxy_port>'}
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
Copy link
Contributor

gconklin commented Sep 2, 2022

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: python-websockets/websockets#364

@fbradyirl
Copy link
Owner

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

@nomadalex
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants