python-slack-sdk: files_upload API - timeout response by server regardless of timeout value passed to web client

Hi, I have this little snippet of code that used to work for me until recently:

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

now I am suddenly getting this 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'}

it seems like the client or server are not considering the timeout parameter that is passed to the WebClient, this response returns exactly 30 seconds after the request initiated, as well as when testing it with a smaller file that takes less than 30 seconds to upload everything works fine

since no changes were made to the code, and the slack_sdk was not updated, I am assuming it is related to a server issue? can any one shed some more information regarding this issue?

using python slack-sdk version 3.13.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 26 (4 by maintainers)

Most upvoted comments

We are facing the same problem.

When uploading a 40 MB file, an error ‘stream timeout’ appears and increasing the timeout does not help.

The funny thing is, the file appears in the slack channel.

Hello! How you guys could break your the one API version? We are facing exactly the same problem with the file upload. We tried to rollback to the previous API version but there is no API versioning at all. What you should do in my opinion: – fix the file upload ASAP – implement the API versioning and do not break the current API version because millions of users have to watch how you test your new API implementation on the production stand.

You are a respectful company, please keep the level on not below your “honor” waterline. 💪🏼

@daniel-moonactive Thanks for your quick reply and understanding here.

Can you suggest how I can try to reproduce this issue without the SDK?

We have curl command examples in the doc: https://api.slack.com/methods/files.upload#examples Using a bit handier tools such as Postman would be an option too.

Hi @seratch here’s the full log using curl

curl -v https://slack.com/api/files.upload -F token=access-token -F channels= "#ios-ajay-test1" -F file=@file_path

*   Trying 13.126.138.201...
* TCP_NODELAY set
* Connected to slack.com (13.126.138.201) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-CHACHA20-POLY1305
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=Slack Technologies, Inc.; CN=slack.com
*  start date: Apr 13 00:00:00 2021 GMT
*  expire date: Apr 18 23:59:59 2022 GMT
*  subjectAltName: host "slack.com" matched cert's "slack.com"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert TLS RSA SHA256 2020 CA1
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fcc26010800)
> POST /api/files.upload HTTP/2
> Host: slack.com
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 195338476
> Content-Type: multipart/form-data; boundary=------------------------ce8e5e2beebe823d
> 
* Connection state changed (MAX_CONCURRENT_STREAMS == 2147483647)!
* We are completely uploaded and fine
< HTTP/2 408 
< x-edge-backend: envoy-www
< content-length: 14
< content-type: text/plain
< x-slack-edge-shared-secret-outcome: no-match
< date: Wed, 26 Jan 2022 08:48:33 GMT
< server: envoy
< via: envoy-edge-bom-3mz6
< 
* Connection #0 to host slack.com left intact
stream timeout* Closing connection -1
curl: (3) URL using bad/illegal format or missing URL
* Closing connection 0