Issue
I'm writing some middle-ware in Python that uses Socket Mode. Non-async testing works fine. But the connect() call fails:
app_token='xapp-XXX'
bot_token='xoxb-XXX'
web_client = AsyncWebClient(bot_token)
sm_client = SocketModeClient(app_token=app_token, web_client=web_client)
sm_client.connect()
Returns:
Traceback (most recent call last):
File "wrapper.py", line 57, in <module>
sm_client.connect()
File "/Library/Python/3.8/site-packages/slack_sdk/socket_mode/builtin/client.py", line 132, in connect
self.wss_uri = self.issue_new_wss_url()
File "/Library/Python/3.8/site-packages/slack_sdk/socket_mode/client.py", line 48, in issue_new_wss_url
return response["url"]
TypeError: 'coroutine' object is not subscriptable
sys:1: RuntimeWarning: coroutine 'AsyncWebClient.apps_connections_open' was never awaited
I can't find anything in the API or SDK documentation about how to use AsyncWebClient in a Socket Mode application. Is this possible?
Solution
In your traceback, it is referencing the builtin
client, aka the concurrent client. You're probably importing this:
from slack_sdk.socket_mode import SocketModeClient
You need to use the async client if you're using the AsyncWebClient
:
from slack_sdk.socket_mode.aiohttp import SocketModeClient
Answered By - Casey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.