box / boxcli

A command line interface for interacting with the Box API.
https://developer.box.com
Apache License 2.0
222 stars 59 forks source link

ESOCKETTIMEDOUT or 502 bad gateway #417

Closed slugbyte closed 1 year ago

slugbyte commented 1 year ago

Description of the Issue

I am trying to upload a files that contains 100 bytes but get either a ESOCKETTIMEDOUT timeout error, or a 502 - Bad Gateway Error.

at first i was getting an ESOCKETTIMEDOUT error, and after looking though github issues #343
I tried following the timeout configuration setting instructions on https://github.com/box/boxcli/blob/main/docs/configuration.md#configure-how-client-retries-calls-and-handles-timeouts

and then I started to get 502 - Bad Gateway errors

the error docs for the box api say to use an exponetail back off strategy, but the cli docs all ready claim to do that.

what should I Do next

Steps to Reproduce

run box files:upload -v --parent-id 0 ./project_id_list.txt

Expected Behavior

i expected to upload a file

Versions Used

@box/cli/3.4.0 linux-x64 node-v16.16.0

Error Message, Including Stack Trace

$ box files:upload -v --parent-id 0 ./project_id_list.txt -- INSERT --

ESOCKETTIMEDOUT Error logs

  box:@box/cli:hooks:init done +0ms
  box init version: @oclif/command@1.5.5 argv: [ 'files:upload', '-v', '--parent-id', '0', './project_id_list.txt' ] +0ms
  box-cli:init Initializing Box CLI +0ms
  box-cli:init Loaded settings {
  box-cli:init   boxReportsFolderPath: '<path on my comupter>',
  box-cli:init   boxReportsFileFormat: 'txt',
  box-cli:init   boxDownloadsFolderPath: '<path on my computer>',
  box-cli:init   outputJson: false,
  box-cli:init   enableProxy: false,
  box-cli:init   proxy: { url: null, username: null, password: null },
  box-cli:init   enableAnalyticsClient: false,
  box-cli:init   analyticsClient: { name: null }
  box-cli:init } +1ms
  box-cli:init Using environment oauth {
  box-cli:init   clientId: '<my oauth id>',
  box-cli:init   clientSecret: '<my oauth secret>',
  box-cli:init   name: 'oauth',
  box-cli:init   cacheTokens: true,
  box-cli:init   authMethod: 'oauth20'
  box-cli:init } +0ms
  box-cli:init SDK client settings { iterators: true, analyticsClient: [Object], request: [Object] } +1ms
  box-cli:execute Starting execution command: files:upload argv: [ '-v', '--parent-id', '0', './project_id_list.txt' ] +0ms
  box-cli:execute Running framework error handler +1m
  box-cli:execute Handling re-thrown error in base command handler +6ms
Error: ESOCKETTIMEDOUT
    at ClientRequest.<anonymous> (/usr/lib/node_modules/@box/cli/node_modules/request/request.js:816:19)
    at Object.onceWrapper (node:events:641:28)
    at ClientRequest.emit (node:events:527:28)
    at TLSSocket.emitRequestTimeout (node:_http_client:771:9)
    at Object.onceWrapper (node:events:641:28)
    at TLSSocket.emit (node:events:539:35)
    at TLSSocket.Socket._onTimeout (node:net:516:8)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)

502 error logs

box:@box/cli:hooks:init done +0ms
box init version: @oclif/command@1.5.5 argv: [ 'files:upload', '-v', '--parent-id', '177977690803', './project_id_list.txt' ] +0ms
box-cli:init Initializing Box CLI +0ms
box-cli:init Loaded settings {
box-cli:init   boxReportsFolderPath: '<path on my comupter>',
box-cli:init   boxReportsFileFormat: 'txt',
box-cli:init   boxDownloadsFolderPath: '<path on my computer>',
box-cli:init   outputJson: false,
box-cli:init   enableProxy: false,
box-cli:init   proxy: { url: null, username: null, password: null },
box-cli:init   enableAnalyticsClient: false,
box-cli:init   analyticsClient: { name: null },
box-cli:init   numMaxRetries: 3,
box-cli:init   retryIntervalMS: 3000,
box-cli:init   uploadRequestTimeoutMS: 3600000
box-cli:init } +1ms
box-cli:init Using environment oauth {
box-cli:init   clientId: '<my id here>',
box-cli:init   clientSecret: '<my secret here',
box-cli:init   name: 'oauth',
box-cli:init   cacheTokens: true,
box-cli:init   authMethod: 'oauth20'
box-cli:init } +0ms
box-cli:init SDK client settings {
iterators: true,
analyticsClient: [Object],
request: [Object],
numMaxRetries: 3,
retryIntervalMS: 3000,
uploadRequestTimeoutMS: 600000 
} +1ms
box-cli:execute Starting execution command: files:upload argv: [ '-v', '--parent-id', '177977690803', './project_id_list.txt' ] +0ms
box-cli:execute Running framework error handler +1m
box-cli:execute Handling re-thrown error in base command handler +9ms
Error: 502 - Bad Gateway
  at createErrorForResponse (/usr/lib/node_modules/@box/cli/node_modules/box-node-sdk/lib/api-request.js:70:12)
  at APIRequest._handleResponse (/usr/lib/node_modules/@box/cli/node_modules/box-node-sdk/lib/api-request.js:180:19)
  at Request.self.callback (/usr/lib/node_modules/@box/cli/node_modules/request/request.js:185:22)
  at Request.emit (node:events:527:28)
  at Request.<anonymous> (/usr/lib/node_modules/@box/cli/node_modules/request/request.js:1154:10)
  at Request.emit (node:events:527:28)
  at IncomingMessage.<anonymous> (/usr/lib/node_modules/@box/cli/node_modules/request/request.js:1076:12)
  at Object.onceWrapper (node:events:641:28)
  at IncomingMessage.emit (node:events:539:35)
  at endReadableNT (node:internal/streams/readable:1345:12)
  at processTicksAndRejections (node:internal/process/task_queues:83:21)
slugbyte commented 1 year ago

also thought it might by good to share that I am able to successfully use the cli to run other commands like folders:get and folders:create

mwwoda commented 1 year ago

Hi @slugbyte This is a known issue - https://github.com/box/boxcli/issues/298 The CLI officially supports node up to v14 - https://github.com/box/boxcli#version-schedule. Try downgrading your node version to v14 and see if that helps.

slugbyte commented 1 year ago

thanks for the quick reply!!!

downgrading to 14 worked perfectly :)