Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to correctly configure a proxy for SocketModeHandler without using environment variables? #1369

Open
Assignees
hello-ashleyintech
Labels
@mehulanshumali

Description

@mehulanshumali

Hello, I'm trying to configure the SocketModeHandler to use an HTTP proxy by passing the proxy parameter directly in its constructor.

My goal is to connect to slack through the specified proxy without needing to set an external environment variable.

However, it appears that the initial HTTPS API call does not use the proxy parameter from the SocketModeHandler constructor, leading to a connection failure. The connection only succeeds if the proxy url is set as an environment variable.

Is this the intended behavior? If so, is the recommended approach to explicitly create a WebClient with the proxy and pass it to the App constructor, or is setting the environment variable the preferred method? It would be helpful to clarify this in the documentation.

Reproducible in:

Theslack_bolt version

slack-bolt==1.22.0slack-sdk==3.34.0

Python runtime version

Python 3.8.10

OS info

(venv) root@host:/home/mehul# uname -v#119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022(venv) root@host:/home/mehul# uname -aLinux host 5.4.0-105-generic#119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux(venv) root@host:/home/mehul# lsb_release -aNo LSB modules are available.Distributor ID:UbuntuDescription:Ubuntu 20.04.4 LTSRelease:20.04Codename:focal

Steps to reproduce:

  1. Use the following Python script (without setting any proxy url as environment variable):
importosfromslack_boltimportAppfromslack_bolt.adapter.socket_modeimportSocketModeHandlerimportlogginglogging.basicConfig(level=logging.DEBUG)# This proxy URL is valid and runningproxy_url="http://<proxy-url>:<port>"app=App(token=os.environ.get("SLACK_BOT_TOKEN"))if__name__=="__main__":handler=SocketModeHandler(app,os.environ.get("SLACK_APP_TOKEN"),proxy=proxy_url    )handler.start()
  1. Run the script.

Expected result:

I expect the script to successfully connect to Slack. The SocketModeHandler should use the provided proxy_url for both its initial HTTPS API call to apps.connections.open and for the final WebSocket connection.

Actual result:

The script fails to connect to slack. The debug logs show that the call tohttps://slack.com/api/auth.test times out or fails with a connection error. It appears this initial call does not use the proxy parameter.

Bot is initializing...DEBUG:slack_bolt.App:Sending a request - url: https://slack.com/api/auth.test, query_params: {}, body_params: {}, files: {}, json_body: None, headers: {'Content-Type':'application/x-www-form-urlencoded','Authorization':'(redacted)','User-Agent':'Bolt/1.22.0 Python/3.8.10 slackclient/3.34.0 Linux/5.4.0-105-generic'}ERROR:slack_bolt.App:Failed to send a request to Slack API server:<urlopen error timed out>INFO:slack_bolt.App:A retry handler found: ConnectionErrorRetryHandlerfor POST https://slack.com/api/auth.test -<urlopen error timed out>INFO:slack_bolt.App:Going to retry the same request: POST https://slack.com/api/auth.test

The script only works if I:

  1. Set a proxy url as an environment variable externally (export proxy_url = "http://proxy-url:port").

Requirements

Please read theContributing guidelines andCode of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp