Skip to content

cause: Error: socket hang up when try to send many requests  #24

@CentralMatthew

Description

@CentralMatthew

I need to translate a lot of data, when i try to do translate in loop i got this error. How i can prevent this?

ConnectionError: Connection failure: socket hang up
at Function.sendAxiosRequest (/Users/matthew/IdeaProjects/backend/node_modules/deepl-node/dist/client.js:163:27)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async HttpClient.sendRequestWithBackoff (/Users/matthew/IdeaProjects/backend/node_modules/deepl-node/dist/client.js:114:28)
at async Translator.translateText (/Users/matthew/IdeaProjects/backend/node_modules/deepl-node/dist/index.js:354:41)
at async /Users/matthew/IdeaProjects/backend/lib/utils/formatDocsJSON.js:156:17
at async Promise.all (index 45)
at async /Users/matthew/IdeaProjects/backend/lib/utils/formatDocsJSON.js:140:16
at async Promise.all (index 3)
at async formatJsonFile (/Users/matthew/IdeaProjects/backend/lib/utils/formatDocsJSON.js:139:18)
at async main (/Users/matthew/IdeaProjects/backend/lib/utils/formatDocsJSON.js:34:5) {
error: AxiosError: socket hang up
at Function.AxiosError.from (/Users/matthew/IdeaProjects/backend/node_modules/axios/dist/node/axios.cjs:789:14)
at RedirectableRequest.handleRequestError (/Users/matthew/IdeaProjects/backend/node_modules/axios/dist/node/axios.cjs:2744:25)
at RedirectableRequest.emit (node:events:525:35)
at ClientRequest.eventHandlers. (/Users/matthew/IdeaProjects/backend/node_modules/follow-redirects/index.js:14:24)
at ClientRequest.emit (node:events:513:28)
at TLSSocket.socketOnEnd (node:_http_client:518:9)
at TLSSocket.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1358:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ECONNRESET',
config: {
transitional: [Object],
adapter: [Array],
transformRequest: [Array],
transformResponse: [Array],
timeout: 20000,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: [Object],
validateStatus: null,
headers: [AxiosHeaders],
url: '/v2/translate',
method: 'post',
baseURL: 'https://api.deepl.com',
responseType: 'text',
data: 'target_lang=en-US&source_lang=de&text=Apikoaortales%2C+klappentragendes+Konduit'
},
request: Writable {
_writableState: [WritableState],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
_options: [Object],
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 79,
_requestBodyBuffers: [Array],
_onNativeResponse: [Function (anonymous)],
_currentRequest: [ClientRequest],
_currentUrl: 'https://api.deepl.com/v2/translate',
_timeout: null,
[Symbol(kCapture)]: false
},
cause: Error: socket hang up
at connResetException (node:internal/errors:705:14)
at TLSSocket.socketOnEnd (node:_http_client:518:23)
at TLSSocket.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1358:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ECONNRESET'
}
},
shouldRetry: false
}

This is my configutration deepl.Translator(config.deeplApiKey, { maxRetries: 50, minTimeout: 20000 });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions