Forum Discussion

rgfpy's avatar
rgfpy
New member | Level 2
7 years ago

Python API Error Upload SSL

Tengo el siguiente error cuando intento hacer upload de un archivo utilizando el ejemplo de github example/back-up-and-restore/backup-and-restore-example.py archivos pequeños de 10Mb lo sube sin problemas pero uno de 20Mb ya salta el error

Versiones utilizadas en Windows 10 Pro x64 y Windows Server 2008R2:

python:3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
dropbox:9.0.0
requests:2.19.1
six:1.11.0
Traceback (most recent call last):
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1055, in _send_output
    self.send(chunk)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 977, in send
    self.sock.sendall(data)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1012, in sendall
    v = self.send(byte_view[count:])
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 981, in send
    return self._sslobj.write(data)
ssl.SSLWantWriteError: The operation did not complete (write) (_ssl.c:2317)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 445, in send
    timeout=timeout
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='content.dropboxapi.com', port=443): Max retries exceeded with url: /2/files/upload (Caused by SSLError(SSLWantWriteError(3, 'The operation did not complete (write) (_ssl.c:2317)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\upload-dropbox.py", line 105, in <module>
    uploadDropbox()
  File ".\upload-dropbox.py", line 30, in uploadDropbox
    dbx.files_upload(f.read(), BACKUPPATH, mode=WriteMode('overwrite'))
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\dropbox\base.py", line 2207, in files_upload
    f,
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\dropbox\dropbox.py", line 274, in request
    timeout=timeout)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\dropbox\dropbox.py", line 365, in request_json_string_with_retry
    timeout=timeout)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\dropbox\dropbox.py", line 449, in request_json_string
    timeout=timeout,
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 559, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 511, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='content.dropboxapi.com', port=443): Max retries exceeded with url: /2/files/upload (Caused by SSLError(SSLWantWriteError(3, 'The operation did not complete (write) (_ssl.c:2317)')))
  • rgfpy's avatar
    rgfpy
    New member | Level 2

    Editando el  archivo C:\Users\rgfpy\AppData\Local\Programs\Python\Python37\lib\site-packages\dropbox\dropbox.py en la línea 129 la variable _DEFAULT_TIMEOUT que por default esta 30 segundos si aumento a más logra subir archivos de más tamaños pero un archivo de 200Mb o mas no sube

    • Greg-DB's avatar
      Greg-DB
      Icon for Dropbox Staff rankDropbox Staff
      Gracias por el informe! Esto parece ser un problema cuando se utiliza el SDK de Dropbox Python con Python 3. Estamos investigando.

      Como solución temporal, intente establecer un tiempo de espera ilimitado al construir su cliente de Dropbox, así:

      dropbox.Dropbox(TOKEN, timeout=None)

      ---

      Disculpe nuestras traducciones Nuestras traducciones fueron creadas usando un traductor en línea. Nos gustaría apoyar todos los idiomas, pero actualmente no estamos equipados para hacerlo. Aquí está la versión en inglés:

      ---

      Please excuse our translations. Our translations were created using an online translator. We'd like to support every language, but we're not currently equipped to do so. Here is the English version:

      ---

      Thanks for the report! This appears to be an issue when using the Dropbox Python SDK with Python 3. We're looking into it.

      As a workaround, please try setting an unlimited timeout when constructing your Dropbox client, like this:

      dropbox.Dropbox(TOKEN, timeout=None)

       

      • leojtonozzi's avatar
        leojtonozzi
        New member | Level 2

        Hello, I am having the exact same issue.

         

        Unfortunately your proposed fix did not fix the issue. Are there any updates to this?

        Thank you.