Receiving an error from server when trying to upload a file

Viewed 1042

I have this snippet of code in Python that is uploading a file to slack, it used to work until recently when suddenly its failing exactly 30 seconds after initiating the upload request due to this server response:

slack_sdk.errors.SlackApiError: Received a response in a non-JSON format: stream timeout The server responded with: {'status': 408, 'headers': {'x-edge-backend': 'envoy-www', 'content-length': '14', 'content-type': 'text/plain', 'x-slack-edge-shared-secret-outcome': 'no-match', 'date': 'Tue, 18 Jan 2022 08:12:58 GMT', 'server': 'envoy', 'via': 'envoy-edge-fra-f6ad', 'connection': 'close'}, 'body': 'stream timeout'}

this is my code (just the relevant lines):

slackClient=slack_sdk.WebClient(token=slackToken, timeout=300)
upload = slackClient.files_upload(file=file, filename=file)

this is not related to the timeout parameter, I tried with and without it (and it used to work as is before)

what is the reason for this error and how can I fix it?

1 Answers

It still seems to be a timeout issue. From the source code of slack sdk for python:

class WebClient(BaseClient):
    ...
    Attributes:
        ...
        timeout (int): The maximum number of seconds the client will wait
            to connect and receive a response from Slack.
            Default is 30 seconds.

If you init a WebClient instance without the timeout parameter, the timeout parameter is 30 seconds by default.

Trying to upload a small size file, or set a longer timeout option, to test is it a real timeout issue.

Related