Skip to content

Commit

Permalink
fix stale connection error
Browse files Browse the repository at this point in the history
  • Loading branch information
rwood-97 committed Sep 15, 2023
1 parent 2f9e209 commit bfb9ea9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions slack_bot/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,14 @@ async def main():
logging.error("SLACK_APP_TOKEN is not set")
sys.exit(1)

# Initialize SocketModeClient with an app-level token + WebClient
# Initialize SocketModeClient with an app-level token + AsyncWebClient
client = SocketModeClient(
# This app-level token will be used only for establishing a connection
app_token=os.environ.get("SLACK_APP_TOKEN"),
# You will be using this WebClient for performing Web API calls in listeners
# You will be using this AsyncWebClient for performing Web API calls in listeners
web_client=AsyncWebClient(token=os.environ.get("SLACK_BOT_TOKEN")),
# To ensure connection doesn't go stale - we can adjust as needed.
ping_interval=60,
)

# Add a new listener to receive messages from Slack
Expand Down

0 comments on commit bfb9ea9

Please sign in to comment.