cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: socket.timeout: The write operation timed out

socket.timeout: The write operation timed out

meister66
Explorer | Level 3
Go to solution

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-res...

 

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

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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.

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

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
Explorer | Level 3
Go to solution

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
Dropbox Staff
Go to solution

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.

meister66
Explorer | Level 3
Go to solution

Tried with a smaller file and it worked. 

With that error messages it never occured to me that filsize might be the issue.

 

Many thanks for your support!

Need more support?