cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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: Dropbox v2 api. Javascript app installed in Windows Server behind proxy

Re: Dropbox v2 api. Javascript app installed in Windows Server behind proxy

Ridvan_
Helpful | Level 6
Go to solution

I have a node.js app which runs on AWS Lambda. The Lambda is connected with a VPC. It goes internet with a static IP. I use v10.23.0 dropbox-sdk-js. It always seems to run on my local but it sometimes runs on the lambda, sometimes gets fetch error.

 

My code is like this:

async function main() {
    const Dropbox = require('dropbox').Dropbox;
    const dropbox = {
        dbx: new Dropbox({
            accessToken: process.env.ACCESS_TOKEN,
            pathRoot: JSON.stringify({ '.tag': 'namespace_id', 'namespace_id': process.env.NAMESPACE_ID })
        })
    };
    const payload = {
        path: '',
        recursive: true,
        include_media_info: false,
        include_deleted: false,
        include_has_explicit_shared_members: true,
        include_mounted_folders: true,
        include_non_downloadable_files: true
    };

    let hasMore = true;
    let entries = [];
    let response;
    let cursor;

    while (hasMore) {
        try {
            if (cursor) {
                response = await dropbox.dbx.filesListFolderContinue({ cursor: cursor });
            }
            else {
                response = await dropbox.dbx.filesListFolderGetLatestCursor(payload);

                response = await dropbox.dbx.filesListFolderContinue({ cursor: response.result.cursor });

            }

            console.info('Entries: ', JSON.stringify(response.result.entries));

            cursor = response.result.cursor;
            entries = entries.concat(response.result.entries);
            hasMore = response.result.has_more;
        }
        catch (error) {
            console.info(error);
            return error;
        }
    }
}

main();

Error log:

2022-01-20T08:22:18.579Z    67caa239-e75c-46ce-be4c-0fcf6c154694    INFO    FetchError: request to https://api.dropboxapi.com/2/files/list_folder/continue failed, reason: connect ETIMEDOUT 162.125.4.19:443
    at ClientRequest.<anonymous> (/var/task/node_modules/dropbox/node_modules/node-fetch/lib/index.js:1483:11)
    at ClientRequest.emit (events.js:400:28)
    at TLSSocket.socketErrorListener (_http_client.js:475:9)
    at TLSSocket.emit (events.js:400:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  type: 'system',
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT'
}


Do you have any idea about the issue?

1 Accepted Solution

Accepted Solutions

Ridvan_
Helpful | Level 6
Go to solution

@Greg-DB I found the problem. An AWS Lambda that is attached to a VPC, causes FetchError problem. I deattached the lambda from VPC. It works fine now. By the way, thanks for your advices.

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

@Ridvan_ You originally posted this in a thread where this issue seemed to be related to the use of a proxy. It sounds like that's not relevant in your case though, so I've split your post to its own thread.

 

Anyway, I see you're getting an ETIMEDOUT error from the fetch network client. An ETIMEDOUT error like this should indicate that the connection took too long and so timed out, though unfortunately there isn't much indication of why that is the case here. For reference, do you only see this on /2/files/list_folder/continue in particular, or does it occur on other endpoints as well?

 

Also, you mentioned that you see this "sometimes". Can you elaborate on how often you see this, and on about what percent of your API calls? If it only occurs occasionally, it may just be due to transient network disruptions or server availability issues, in which case you could add some automatic retries to handle this.

Ridvan_
Helpful | Level 6
Go to solution

@Greg-DB I found the problem. An AWS Lambda that is attached to a VPC, causes FetchError problem. I deattached the lambda from VPC. It works fine now. By the way, thanks for your advices.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Ridvan_ Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?