We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

meister66's avatar
meister66
Explorer | Level 3
7 years ago

socket.timeout: The write operation timed out

Hi,

 

I am trying to uload a single file based on the example code from here: https://github.com/dropbox/dropbox-sdk-python/blob/master/example/back-up-and-restore/backup-and-restore-example.py

 

On my Mac ist works flawlessly. But when I run the very same code on my Windows server 2018 R2 it throws the follwoing error. Python is the same version - 3.5.2. Any ideas are more than welcome.

 

C:\Users\Administrator\Documents\scripts\web2dropbox>python www2dropbox.py

Creating a Dropbox object...
upload file JTL-20180331.tar.bz2 to Dropbox /JTL-20180331.tar.bz2
Uploading ./temp/JTL-20180331.tar.bz2 to Dropbox as /JTL-20180331.tar.bz2...
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\urllib3\connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\urllib3\connectionpool.py", line 357, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\http\c
lient.py", line 1106, in request
    self._send_request(method, url, body, headers)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\http\c
lient.py", line 1151, in _send_request
    self.endheaders(body)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\http\c
lient.py", line 1102, in endheaders
    self._send_output(message_body)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\http\c
lient.py", line 936, in _send_output
    self.send(message_body)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\http\c
lient.py", line 908, in send
    self.sock.sendall(data)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\ssl.py
", line 891, in sendall
    v = self.send(data[count:])
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\ssl.py
", line 861, in send
    return self._sslobj.write(data)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\ssl.py
", line 586, in write
    return self._sslobj.write(data)
socket.timeout: The write operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\requests\adapters.py", line 440, in send
    timeout=timeout
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\urllib3\connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\urllib3\util\retry.py", line 357, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\urllib3\packages\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\urllib3\connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\urllib3\connectionpool.py", line 357, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\http\c
lient.py", line 1106, in request
    self._send_request(method, url, body, headers)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\http\c
lient.py", line 1151, in _send_request
    self.endheaders(body)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\http\c
lient.py", line 1102, in endheaders
    self._send_output(message_body)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\http\c
lient.py", line 936, in _send_output
    self.send(message_body)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\http\c
lient.py", line 908, in send
    self.sock.sendall(data)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\ssl.py
", line 891, in sendall
    v = self.send(data[count:])
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\ssl.py
", line 861, in send
    return self._sslobj.write(data)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\ssl.py
", line 586, in write
    return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', timeout('The write ope
ration timed out',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "www2dropbox.py", line 186, in <module>
    main()
  File "www2dropbox.py", line 180, in main
    backup2dbx(dbx, local_filename, backup_path + filename)
  File "www2dropbox.py", line 27, in backup2dbx
    dbx.files_upload(f.read(), backup_path, mode=WriteMode('overwrite'))
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\dropbox\base.py", line 2125, in files_upload
    f,
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\dropbox\dropbox.py", line 272, in request
    timeout=timeout)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\dropbox\dropbox.py", line 363, in request_json_string_with_retry
    timeout=timeout)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\dropbox\dropbox.py", line 447, in request_json_string
    timeout=timeout,
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\requests\sessions.py", line 555, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\requests\sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\requests\sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p
ackages\requests\adapters.py", line 490, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', timeout('The write
operation timed out',))

C:\Users\Administrator\Documents\scripts\web2dropbox>

Many Thanks,

 

Meister

  • Greg-DB's avatar
    Greg-DB
    7 years ago

    Thanks! The single files_upload method used in that sample is only meant for files up to 150 MB in size. That isn't necessarily a strict limit though, so files larger than that may or may not fail, and it may be inconsistent across different machines/network connections. For large files, you'll need to switch to upload sessions.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    How big is the file you're trying to upload when this occurs? The sample doesn't use upload sessions, so it can only handle small files. If you need it to support large files, you'll need to update it to use upload sessions.

     

    Otherwise, this might just indicate transient server/network issues. If you're still seeing this, there may be something interfering with your connection. Do you have anything on that network connection, e.g., firewall or proxy, that may be preventing your app from successfully connecting to the Dropbox servers?

    • meister66's avatar
      meister66
      Explorer | Level 3

      The file is 250-300MB. As mentioned, it worked on my Mac on which I tested the script first with the same file. The datapath is identical and local firewall on the windows server is switched off

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        Thanks! The single files_upload method used in that sample is only meant for files up to 150 MB in size. That isn't necessarily a strict limit though, so files larger than that may or may not fail, and it may be inconsistent across different machines/network connections. For large files, you'll need to switch to upload sessions.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,877 PostsLatest Activity: 12 months ago
325 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!