Jesus/dropbox_api

timeout issues

jess opened this issue · 5 comments

jess commented

I'm having timeout issues when fetching a folder. I can use the dropbox api explorer and curl and all works fine, but as soon as I try in ruby it times out.

Any help would be greatly appreciated.

jess commented

More info....

I'm basically having trouble connecting to the dropbox api with any http client:

With excon ruby client:

D, [2017-11-28T09:26:47.224529 #2334] DEBUG -- : [httplog] Sending: POST https://api.dropboxapi.com:443/2/files/list_folder 
D, [2017-11-28T09:26:47.224624 #2334] DEBUG -- : [httplog] Header: Content-Type: application/json 
D, [2017-11-28T09:26:47.224656 #2334] DEBUG -- : [httplog] Header: Authorization: Bearer DznxGSDVMzUAAAAAAAC9gfmiB4muiwgYQsurRzsx5y1v1jTwGyvWhNSFad2Zy60P 
D, [2017-11-28T09:26:47.224683 #2334] DEBUG -- : [httplog] Header: Host: api.dropboxapi.com:443 
D, [2017-11-28T09:26:47.224751 #2334] DEBUG -- : [httplog] Data: { "path":"" } 
D, [2017-11-28T09:26:47.224825 #2334] DEBUG -- : [httplog] Connecting: api.dropboxapi.com:443 
D, [2017-11-28T09:28:04.329480 #2334] DEBUG -- : [httplog] Status: 200 
D, [2017-11-28T09:28:04.329544 #2334] DEBUG -- : [httplog] Header: Server: nginx 
D, [2017-11-28T09:28:04.329569 #2334] DEBUG -- : [httplog] Header: Date: Tue, 28 Nov 2017 14:28:05 GMT 
D, [2017-11-28T09:28:04.329590 #2334] DEBUG -- : [httplog] Header: Content-Type: application/json 
D, [2017-11-28T09:28:04.329615 #2334] DEBUG -- : [httplog] Header: Connection: keep-alive 
D, [2017-11-28T09:28:04.329633 #2334] DEBUG -- : [httplog] Header: Vary: Accept-Encoding, Accept-Encoding 
D, [2017-11-28T09:28:04.329650 #2334] DEBUG -- : [httplog] Header: Cache-Control: no-cache 
D, [2017-11-28T09:28:04.329667 #2334] DEBUG -- : [httplog] Header: Pragma: no-cache 
D, [2017-11-28T09:28:04.329686 #2334] DEBUG -- : [httplog] Header: X-Content-Type-Options: nosniff 
D, [2017-11-28T09:28:04.329707 #2334] DEBUG -- : [httplog] Header: X-Dropbox-Request-Id: 4d501fab59ee12980ca8706dfdda72af 
D, [2017-11-28T09:28:04.329728 #2334] DEBUG -- : [httplog] Header: X-Frame-Options: SAMEORIGIN 
D, [2017-11-28T09:28:04.329744 #2334] DEBUG -- : [httplog] Header: X-Server-Response-Time: 377 
D, [2017-11-28T09:28:04.329798 #2334] DEBUG -- : [httplog] Response: 
{"entries": [{".tag": "file", "name": "City of Monroe Employment Application.pdf", "path_lower": "/city of monroe employment application.pdf", "path_display": "/City of Monroe Employment Application.pdf", "id": "id:vBEz4cx_PnAAAAAAAAAACA", "client_modified": "2014-04-21T12:36:20Z", "server_modified": "2017-11-27T22:54:46Z", "rev": "16e73af20", "size": 2308864, "content_hash": "f2c98ee327b25a31987e49a1948390ac70e263046747f7fe30a8125c564affbf"}, {".tag": "file", "name": "City of Monroe Newcomer Information.pdf", "path_lower": "/city of monroe newcomer information.pdf", "path_display": "/City of Monroe Newcomer Information.pdf", "id": "id:vBEz4cx_PnAAAAAAAAAABw", "client_modified": "2014-06-17T12:41:58Z", "server_modified": "2017-11-27T22:54:46Z", "rev": "26e73af20", "size": 883649, "content_hash": "10f5911c79d75d99a82d7195948c024a2e9c6d08b17697afe2e20946891c3b30"}, {".tag": "file", "name": "2017-11-27_18-03-59.mp4", "path_lower": "/2017-11-27_18-03-59.mp4", "path_display": "/2017-11-27_18-03-59.mp4", "id": "id:vBEz4cx_PnAAAAAAAAAADA", "client_modified": "2017-11-27T23:21:46Z","server_modified": "2017-11-27T23:23:00Z", "rev": "36e73af20", "size": 47220201, "content_hash": "8c8dce38010fbd86220e1d3bc0c15644f81507342ccd170f504797860dd28bf3"}], "cursor": "AAGerjB1j3tnrxeedyB1lZt66KQJctBtKzfb04v4W86QpIf0tWKDdwUHs8tnwo1XHzCPa-I3pXWfxG0RpaaIY3Wx91C0tRng4SZuh3zxJQQMOK_ZSOyMwJfUE2jRVsCoioUJ0lXmoiq1bgZs5D09zbUA", "has_more": false} 
D, [2017-11-28T09:28:04.331639 #2334] DEBUG -- : [httplog] Benchmark: 77.107151 seconds 
=> #<Excon::Response:0x00007ff761e003c0 
@body= 
"{\"entries\": [{\".tag\": \"file\", \"name\": \"City of Monroe Employment Application.pdf\", \"path_lower\": \"/city of monroe employment application.pdf\", \"path_display\": \"/City of Monroe Employment Application.pdf\", \"id\": \"id:vBEz4cx_PnAAAAAAAAAACA\", \"client_modified\": \"2014-04-21T12:36:20Z\", \"server_modified\": \"2017-11-27T22:54:46Z\", \"rev\": \"16e73af20\", \"size\": 2308864, \"content_hash\": \"f2c98ee327b25a31987e49a1948390ac70e263046747f7fe30a8125c564affbf\"}, {\".tag\": \"file\", \"name\": \"City of Monroe Newcomer Information.pdf\", \"path_lower\": \"/city of monroe newcomer information.pdf\", \"path_display\": \"/City of Monroe Newcomer Information.pdf\", \"id\": \"id:vBEz4cx_PnAAAAAAAAAABw\", \"client_modified\": \"2014-06-17T12:41:58Z\", \"server_modified\": \"2017-11-27T22:54:46Z\", \"rev\": \"26e73af20\", \"size\": 883649, \"content_hash\": \"10f5911c79d75d99a82d7195948c024a2e9c6d08b17697afe2e20946891c3b30\"}, {\".tag\": \"file\", \"name\": \"2017-11-27_18-03-59.mp4\", \"path_lower\": \"/2017-11-27_18-03-59.mp4\", \"path_display\": \"/2017-11-27_18-03-59.mp4\", \"id\": \"id:vBEz4cx_PnAAAAAAAAAADA\", \"client_modified\": \"2017-11-27T23:21:46Z\", \"server_modified\": \"2017-11-27T23:23:00Z\", \"rev\": \"36e73af20\", \"size\": 47220201, \"content_hash\": \"8c8dce38010fbd86220e1d3bc0c15644f81507342ccd170f504797860dd28bf3\"}], \"cursor\": \"AAGerjB1j3tnrxeedyB1lZt66KQJctBtKzfb04v4W86QpIf0tWKDdwUHs8tnwo1XHzCPa-I3pXWfxG0RpaaIY3Wx91C0tRng4SZuh3zxJQQMOK_ZSOyMwJfUE2jRVsCoioUJ0lXmoiq1bgZs5D09zbUA\", \"has_more\": false}", 
@data= 
{:body=> 
"{\"entries\": [{\".tag\": \"file\", \"name\": \"City of Monroe Employment Application.pdf\", \"path_lower\": \"/city of monroe employment application.pdf\", \"path_display\": \"/City of Monroe Employment Application.pdf\", \"id\": \"id:vBEz4cx_PnAAAAAAAAAACA\", \"client_modified\": \"2014-04-21T12:36:20Z\", \"server_modified\": \"2017-11-27T22:54:46Z\", \"rev\": \"16e73af20\", \"size\": 2308864, \"content_hash\": \"f2c98ee327b25a31987e49a1948390ac70e263046747f7fe30a8125c564affbf\"}, {\".tag\": \"file\", \"name\": \"City of Monroe Newcomer Information.pdf\", \"path_lower\": \"/city of monroe newcomer information.pdf\", \"path_display\": \"/City of Monroe Newcomer Information.pdf\", \"id\": \"id:vBEz4cx_PnAAAAAAAAAABw\", \"client_modified\": \"2014-06-17T12:41:58Z\", \"server_modified\": \"2017-11-27T22:54:46Z\", \"rev\": \"26e73af20\", \"size\": 883649, \"content_hash\": \"10f5911c79d75d99a82d7195948c024a2e9c6d08b17697afe2e20946891c3b30\"}, {\".tag\": \"file\", \"name\": \"2017-11-27_18-03-59.mp4\", \"path_lower\": \"/2017-11-27_18-03-59.mp4\", \"path_display\": \"/2017-11-27_18-03-59.mp4\", \"id\": \"id:vBEz4cx_PnAAAAAAAAAADA\", \"client_modified\": \"2017-11-27T23:21:46Z\", \"server_modified\": \"2017-11-27T23:23:00Z\", \"rev\": \"36e73af20\", \"size\": 47220201, \"content_hash\": \"8c8dce38010fbd86220e1d3bc0c15644f81507342ccd170f504797860dd28bf3\"}], \"cursor\": \"AAGerjB1j3tnrxeedyB1lZt66KQJctBtKzfb04v4W86QpIf0tWKDdwUHs8tnwo1XHzCPa-I3pXWfxG0RpaaIY3Wx91C0tRng4SZuh3zxJQQMOK_ZSOyMwJfUE2jRVsCoioUJ0lXmoiq1bgZs5D09zbUA\", \"has_more\": false}", 
:cookies=>[], 
:host=>"api.dropboxapi.com", 
:headers=> 
{"Server"=>"nginx", 
"Date"=>"Tue, 28 Nov 2017 14:28:05 GMT", 
"Content-Type"=>"application/json", 
"Connection"=>"keep-alive", 
"Vary"=>"Accept-Encoding, Accept-Encoding", 
"Cache-Control"=>"no-cache", 
"Pragma"=>"no-cache", 
"X-Content-Type-Options"=>"nosniff", 
"X-Dropbox-Request-Id"=>"4d501fab59ee12980ca8706dfdda72af", 
"X-Frame-Options"=>"SAMEORIGIN", 
"X-Server-Response-Time"=>"377"}, 
:path=>"/2/files/list_folder", 
:port=>443, 
:status=>200, 
:status_line=>"HTTP/1.1 200 OK\r\n", 
:reason_phrase=>"OK", 
:remote_ip=>"162.125.4.7", 
:local_port=>62007, 
:local_address=>"192.168.254.9"}, 
@headers= 
{"Server"=>"nginx", 
"Date"=>"Tue, 28 Nov 2017 14:28:05 GMT", 
"Content-Type"=>"application/json", 
"Connection"=>"keep-alive", 
"Vary"=>"Accept-Encoding, Accept-Encoding", 
"Cache-Control"=>"no-cache", 
"Pragma"=>"no-cache", 
"X-Content-Type-Options"=>"nosniff", 
"X-Dropbox-Request-Id"=>"4d501fab59ee12980ca8706dfdda72af", 
"X-Frame-Options"=>"SAMEORIGIN", 
"X-Server-Response-Time"=>"377"}, 
@local_address="192.168.254.9", 
@local_port=62007, 
@remote_ip="162.125.4.7", 
@status=200>

With HTTP ruby lib

D, [2017-11-28T09:32:57.861774 #2500] DEBUG -- : [httplog] Sending: POST https://api.dropboxapi.com/2/files/list_folder 
D, [2017-11-28T09:32:57.861947 #2500] DEBUG -- : [httplog] Header: Content-Type: application/json 
D, [2017-11-28T09:32:57.862001 #2500] DEBUG -- : [httplog] Header: Authorization: Bearer DznxGSDVMzUAAAAAAAC9gfmiB4muiwgYQsurRzsx5y1v1jTwGyvWhNSFad2Zy60P 
D, [2017-11-28T09:32:57.862028 #2500] DEBUG -- : [httplog] Header: Connection: close 
D, [2017-11-28T09:32:57.862051 #2500] DEBUG -- : [httplog] Header: Host: api.dropboxapi.com 
D, [2017-11-28T09:32:57.862078 #2500] DEBUG -- : [httplog] Header: User-Agent: http.rb/2.2.1 
D, [2017-11-28T09:32:57.862126 #2500] DEBUG -- : [httplog] Data: {"path":""} 
D, [2017-11-28T09:32:57.862199 #2500] DEBUG -- : [httplog] Connecting: api.dropboxapi.com:443 
D, [2017-11-28T09:34:17.269494 #2500] DEBUG -- : [httplog] Status: 200 
D, [2017-11-28T09:34:17.269628 #2500] DEBUG -- : [httplog] Benchmark: 79.400254 seconds 
D, [2017-11-28T09:34:17.269758 #2500] DEBUG -- : [httplog] Header: Server: nginx 
D, [2017-11-28T09:34:17.269785 #2500] DEBUG -- : [httplog] Header: Date: Tue, 28 Nov 2017 14:34:17 GMT 
D, [2017-11-28T09:34:17.269809 #2500] DEBUG -- : [httplog] Header: Content-Type: application/json 
D, [2017-11-28T09:34:17.269828 #2500] DEBUG -- : [httplog] Header: Transfer-Encoding: chunked 
D, [2017-11-28T09:34:17.273237 #2500] DEBUG -- : [httplog] Header: Connection: close 
D, [2017-11-28T09:34:17.273265 #2500] DEBUG -- : [httplog] Header: Vary: ["Accept-Encoding", "Accept-Encoding"] 
D, [2017-11-28T09:34:17.273281 #2500] DEBUG -- : [httplog] Header: Cache-Control: no-cache 
D, [2017-11-28T09:34:17.273294 #2500] DEBUG -- : [httplog] Header: Pragma: no-cache 
D, [2017-11-28T09:34:17.273307 #2500] DEBUG -- : [httplog] Header: X-Content-Type-Options: nosniff 
D, [2017-11-28T09:34:17.273320 #2500] DEBUG -- : [httplog] Header: X-Dropbox-Request-Id: 1528818e5f315ff8386500ae092ef5a2 
D, [2017-11-28T09:34:17.273334 #2500] DEBUG -- : [httplog] Header: X-Frame-Options: SAMEORIGIN 
D, [2017-11-28T09:34:17.273346 #2500] DEBUG -- : [httplog] Header: X-Server-Response-Time: 341 
D, [2017-11-28T09:34:17.273614 #2500] DEBUG -- : [httplog] Response: 
{"entries": [{".tag": "file", "name": "City of Monroe Employment Application.pdf", "path_lower": "/city of monroe employment application.pdf", "path_display": "/City of Monroe Employment Application.pdf", "id": "id:vBEz4cx_PnAAAAAAAAAACA", "client_modified": "2014-04-21T12:36:20Z", "server_modified": "2017-11-27T22:54:46Z", "rev": "16e73af20", "size": 2308864, "content_hash": "f2c98ee327b25a31987e49a1948390ac70e263046747f7fe30a8125c564affbf"}, {".tag": "file", "name": "City of Monroe Newcomer Information.pdf", "path_lower": "/city of monroe newcomer information.pdf", "path_display": "/City of Monroe Newcomer Information.pdf", "id": "id:vBEz4cx_PnAAAAAAAAAABw", "client_modified": "2014-06-17T12:41:58Z", "server_modified": "2017-11-27T22:54:46Z", "rev": "26e73af20", "size": 883649, "content_hash": "10f5911c79d75d99a82d7195948c024a2e9c6d08b17697afe2e20946891c3b30"}, {".tag": "file", "name": "2017-11-27_18-03-59.mp4", "path_lower": "/2017-11-27_18-03-59.mp4", "path_display": "/2017-11-27_18-03-59.mp4", "id": "id:vBEz4cx_PnAAAAAAAAAADA", "client_modified": "2017-11-27T23:21:46Z","server_modified": "2017-11-27T23:23:00Z", "rev": "36e73af20", "size": 47220201, "content_hash": "8c8dce38010fbd86220e1d3bc0c15644f81507342ccd170f504797860dd28bf3"}], "cursor": "AAFryyzVP9LoF6Cfd_wU8eNSZGq4wrvZEUaTcdtBbXQ_mvnVKMcRSglaAZoyKmSOqoHaS9QPBy-InP186yaZFg2kM_lRZIT5tfmrgG4LAdkuuQO7xXqIVkdF2aGwxIe3lYukm_GmgYdoCZeA9uZI7msY", "has_more": false} 
=> #<HTTP::Response/1.1 200 OK {"Server"=>"nginx", "Date"=>"Tue, 28 Nov 2017 14:34:17 GMT", "Content-Type"=>"application/json", "Transfer-Encoding"=>"chunked", "Connection"=>"close", "Vary"=>["Accept-Encoding", "Accept-Encoding"], "Cache-Control"=>"no-cache", "Pragma"=>"no-cache", "X-Content-Type-Options"=>"nosniff", "X-Dropbox-Request-Id"=>"1528818e5f315ff8386500ae092ef5a2", "X-Frame-Options"=>"SAMEORIGIN", "X-Server-Response-Time"=>"341"}>
jess commented

Benchmark is consistently around 75-80 seconds!

jess commented

but curl is super fast:

time curl -X POST https://api.dropboxapi.com/2/files/list_folder   --header 'Authorization: Bear
er DznxGSDVMzUAAAAAAAC9gfmiB4muiwgYQsurRzsx5y1v1jTwGyvWhNSFad2Zy60P'   --header 'Content-Type: application/json'   --header 'Dropbox-API-Select-User: '   --
data '{"path":""}'
{"entries": [{".tag": "file", "name": "City of Monroe Employment Application.pdf", "path_lower": "/city of monroe employment application.pdf", "path_display": "/City of Monroe Employment Application.pdf", "id": "id:vBEz4cx_PnAAAAAAAAAACA", "client_modified": "2014-04-21T12:36:20Z", "server_modified": "2017-11-27T22:54:46Z", "rev": "16e73af20", "size": 2308864, "content_hash": "f2c98ee327b25a31987e49a1948390ac70e263046747f7fe30a8125c564affbf"}, {".tag": "file", "name": "City of Monroe Newcomer Information.pdf", "path_lower": "/city of monroe newcomer information.pdf", "path_display": "/City of Monroe Newcomer Information.pdf", "id": "id:vBEz4cx_PnAAAAAAAAAABw", "client_modified": "2014-06-17T12:41:58Z", "server_modified": "2017-11-27T22:54:46Z", "rev": "26e73af20", "size": 883649, "content_hash": "10f5911c79d75d99a82d7195948c024a2e9c6d08b17697afe2e20946891c3b30"}, {".tag": "file", "name": "2017-11-27_18-03-59.mp4", "path_lower": "/2017-11-27_18-03-59.mp4", "path_display": "/2017-11-27_18-03-59.mp4", "id": "id:vBEz4cx_PnAAAAAAAAAADA", "client_modified": "2017-11-27T23:21:46Z","server_modified": "2017-11-27T23:23:00Z", "rev": "36e73af20", "size": 47220201, "content_hash": "8c8dce38010fbd86220e1d3bc0c15644f81507342ccd170f504797860dd28bf3"}], "cursor": "AAEfkmf11E_vMKlqzTZgPXHFtqffwkENXkAO2F6kcvcUP9FgCHajQVkMgr0Vd3kWDzyWeKyehESeIhYBQ9lZ-xF9X_Et5LoyaaA0xU9jk6O-oyIOJc3HlyK006_hNK1z4NHnp6IVPJK-2R25CnL6nJra", "has_more": false}
real    0m0.867s
user    0m0.022s
sys     0m0.014s
jess commented

I think I found the issue for anyone that might have the problem in the future. My ipv6 connection was not working and it must have been taking about 75 seconds to revert to ipv4. I had similar issue with bitbucket in the past where things would work, but super slow...I'm not sure why curl would be immune though.

http://ipv6-test.com/

Resetting my modem did the trick...

Jesus commented

That's interesting... glad that you figured it out!