0

An error occurred during the upload a file to SauceLabs:

Exception: During uploading the App file an exception occurred: HTTPSConnectionPool(host='api.us-west-1.saucelabs.com', port=443): Max retries exceeded with url: /v1/storage/upload (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:2393)')))

This is the code I use for uploading files to SauceLabs:

    def uploadApp(self, file_path: str, file_name: str, description: str = None) -> str:
        """
        Uploads an app file to Sauce Storage for the purpose of mobile app testing.
         Sauce Storage supports app files in *.apk, *.aab, *.ipa, or *.zip format, up to 4GB.

        Args:
        - app_path (str): The local path to the app file you want to upload. For example: '/path/to/the/folder/'
        - app_file_name (str): The name of the app file, including the file type extension.
        - description (str): An optional description for the app.

        Returns:
        -  The ID of the uploaded app.

        Raises:
        - Exception: If an error occurs while uploading the app file.
        """

        if not file_path.endswith(os.path.sep):
            file_path = file_path + os.path.sep

        app_file = os.path.join(file_path, file_name)
        form_data = {
            "payload": (app_file, open(app_file, "rb")),
            "name": file_name,
            "description": description
        }
        try:
            response = requests.post('https://api.us-west-1.saucelabs.com/v1/storage/upload',
                                     auth=(self.username, self.access_key),
                                     files=form_data, timeout=200, verify=False)
            file_id = response.json().get('item', {}).get('id')
            return file_id
        except Exception as ex:
            msg = f'During uploading the App file an exception occurred: {ex}'
            raise Exception(msg)

I have already tried many different variations of the code, but nothing helps. I would be very grateful for any tips you could provide!

Alex AL
  • 1
  • 2

1 Answers1

0

The EOF error is suspicious. I'd bet there's a HTTPS certificate issue or a Proxy of some kind involved here. Check this answer from another SO post https://stackoverflow.com/a/50681396/13186962

Note: I don't think there's a problem with your code, nor with Sauce Labs. See the status page here, it looks OK https://status.saucelabs.com/

mdpb
  • 31
  • 1
  • Hi @mdsauce, I checked your answer earlier. My "tls_version":"TLS 1.3". In addition, I've installed the newest versions of cryptography (39.0.2) and pyopenssl (23.0.0) packages. But this error did not disappear. – Alex AL Mar 07 '23 at 18:52
  • And you're not using a HTTP proxy of any kind? Even something that's transparently proxying in the background? This is a good example of a situation where you MUST use a Proxy https://stackoverflow.com/a/71726484/13186962. If you're on a corporate network this is pretty normal and you may have to use the `proxies` argument for requests – mdpb Mar 14 '23 at 15:21
  • To add, I ran the code and the app was uploaded fine. I changed verify to True to get rid of the warning and because Sauce Labs does have a valid HTTPS certificate. You're safe to set that to True FYI. I was not on a coporate controlled network, just a normal personal wifi access point. Nor was I on a VPN or anything of the sort. Didn't get a error like yours, python just exited with a 0 status and uploaded the app. – mdpb Mar 14 '23 at 15:45