Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting ECONNRESET Error: socket hang up error #75

Open
alok2k5ingh opened this issue Aug 5, 2022 · 4 comments
Open

Getting ECONNRESET Error: socket hang up error #75

alok2k5ingh opened this issue Aug 5, 2022 · 4 comments

Comments

@alok2k5ingh
Copy link

Trying to implement the same example as mentioned in the README file but getting the error:
ECONNRESET Error: socket hang up error

Have checkup the token and splunk HEC endpoint, it's working.
Can someone please help

Tried on:
Node version: v14.17.6

"dependencies": {
"splunk-logging": "^0.11.1"
}

@dkoloditch
Copy link

+1

@dkoloditch
Copy link

@alok2k5ingh Here's an alternate solution using the axios library:

const axios = require('axios');

const splunkCollectorUrl = 'https://<yoursubdomain>.splunkcloud.com/services/collector/event'
const context = {
  event: {
    message: 'hello world'
  },
  sourcetype: 'manual'
};
const axiosOptions = {
  url: splunkCollectorUrl,
  method: 'POST',
  data: context,
  headers: {
    'Authorization': `Splunk ${splunkToken}`
  }
}

axios(axiosOptions);

@bmccleave
Copy link

I've hit this issue when attempting publish to splunkcloud as well. I found the removing the port from the url here

requestOptions.url = this.config.protocol + "://" + this.config.host + ":" + this.config.port + this.config.path;
fixes it.

Here is the current line:

requestOptions.url = this.config.protocol + "://" + this.config.host + ":" + this.config.port + this.config.path;

Changing it to this resolved the issue for me:

requestOptions.url = this.config.protocol + "://" + this.config.host + this.config.path;

This is just a hack. Ideally there would be a configuration option to allow the URL to be explicitly passed without a port

@serdalis
Copy link

serdalis commented Sep 7, 2022

This issue is because the library is pulling the URL apart and looking for the pieces it needs to reconstruct it when making a request.

The problem is, if it doesn't find a piece it will replace it with the default value. In this case, the default port is 8088.
Changing the url to (note the 443 port):

const splunkCollectorUrl = 'https://<yoursubdomain>.splunkcloud.com:443/services/collector/event'

will fix the issue you're having.

The problem is from these lines:

config.port = parsed.port;

ret.port = utils.orByFalseyProp("port", config, ret, defaultConfig);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants