Skip to content

Received invalid socket from the current connection #428

@algv

Description

@algv

Describe the bug

Curl.perform() fails with "Received invalid socket from the current connection" after redirects and connection close

This happens after a series of successful HTTP requests with redirects (302 Found). The final response is 200 OK with the header Connection: close, and then the error occurs.

To Reproduce

const { Curl } = require('node-libcurl');

function test() {
  const curl = new Curl();

  const url = 'https://keycloak.digtlab.ru';

  curl.setOpt(Curl.option.VERBOSE, true);
  curl.setOpt(Curl.option.SSL_VERIFYHOST, false)
  curl.setOpt(Curl.option.SSL_VERIFYPEER, false);
  curl.setOpt(Curl.option.FOLLOWLOCATION, true)
  curl.setOpt('URL', url);

  curl.on('end', function (statusCode, data, headers) {
    try {
      console.log(statusCode);
    } catch (e) {
      console.error('Response error:', e);
    }
    curl.close();
  });

  curl.on('error', function (err) {
    console.error('Curl error:', err);
    curl.close();
  });

  curl.perform();
}

test();

Version information:

Version: v3.0.0-node-v93

OS: Windows 10
Node.js Version: v16.20.2

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions