undici: SocketError: other side closed
Upon connecting to a proxy with user:pass it’s all good, but when I try to make a request to an proxy which is IP authenticated, I get ‘SocketError: other side closed’. I’m not sending the proxy-authorization header as it’s not needed. Blanked the proxy ip and port below.
var Client = require('undici');
(async ()=>{
const client = new Client("http://proxyip:proxyport")
const response = await client.request({
method: 'GET',
path: 'https://api.ipify.org?format=json',
headers: {
//'proxy-authorization': `Basic ${Buffer.from(':').toString('base64')}`
}
})
response.body.setEncoding('utf8')
let data = ''
for await (const chunk of response.body) {
data += chunk
}
//
console.log(response.statusCode)
console.log(JSON.parse(data))
client.close()
})();
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 43 (29 by maintainers)
Commits related to this issue
- Add tests for issue 583. Closes #583 — committed to nodejs/undici by mcollina 3 years ago
- Fixed AuthenticatedHttpRequester failing during quick successive call within the timeout of the last one - https://github.com/nodejs/undici/issues/583 — committed to mojaloop/security-bc by pedrosousabarreto 8 months ago
This issue has been closed since 3 years ago; please open a new one with a description and an Minimum Reproducible Example if possible 🙂
I dont think this issue should be closed. @mcollina
You need to consume or destroy the response body. I think the docs mention this.
Thanks! Tracking down those conditions is hard 😦.
Alright, I will see if I can narrow it down.