question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Socket hang up with ExpressJS

See original GitHub issue

I’ve setup my server with elastic-apm-node, and it run ok. But after every period of time (30-60 min), it causes an error like below:

Error: socket hang up
    at createHangUpError (_http_client.js:331:15)
    at Socket.socketOnEnd (_http_client.js:423:23)
    at emitNone (events.js:111:20)
    at Socket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1055:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)

This error made my server down too, so I need to restart it. After removed the code, everthing okay now. This is my config code:

require('elastic-apm-node').start({
  serviceName: '...',
  secretToken: '...',
  instrument: true,
  captureBody: 'all',
  errorOnAbortedRequests: true,
  serverUrl: 'http://...:8200',
  active: process.env.NODE_ENV === 'production'
})

Version

Elasticsearch, Kibana, APM v6.2.1
NodeJS v8.9.4
ExpressJS v4.15.2

I searched for this error, but there’s no results with apm-server. Is this a known issue, or my configuration miss something? Please help me to fix this. Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:31 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
jppellerincommented, Mar 21, 2018

To chime in here: We were seeing the same Socket hang up error on version 1.1.1, running a hapi server. After updating to version 1.2.1, we have not seen the error again. Mind you, we have cut down our sample rate to 0.5.

For reference purposes, here is our config:

import Config from "./config/configuration";

import * as APM from "elastic-apm-node";
APM.start({
    active: Config.get("/elasticSearch/apm/active"),
    serviceName: Config.get("/elasticSearch/apm/serviceName"),
    serverUrl: Config.get("/elasticSearch/apm/url"),
    transactionSampleRate: 0.5
});

We will eventually try to up the transactionSampleRate back up to the default 100%, but are not setup to make the change safely at this point. Will follow up once we properly test.

2reactions
7agustibmcommented, Feb 23, 2018

I had the same problem. I configured APM Server with these values and I solved it.

apm-server.yml:

apm-server:
  host: 0.0.0.0:8200
  
output.elasticsearch:
  hosts: ['elasticsearch:9200']
Read more comments on GitHub >

github_iconTop Results From Across the Web

NodeJS - What does "socket hang up" actually mean?
It means that socket does not send connection end event within the timeout period. If you are getting the request for cheerio via...
Read more >
NodeJS - What does socket hang up actually mean - Edureka
When a socket hang up is thrown, one of two things happens: When you're a customer, When you send a request to a...
Read more >
Hang in There! (A solution to socket hang up) - Medium
(A solution to socket hang up) Recently, while watching a YouTube video about how to create a Node. js backend (Building a RESTful...
Read more >
How to handle a socket hang up error in Node.js usually - Quora
Socket hang up error are usually errors when requests coming to your server are more than it can handle. This might be b...
Read more >
Socket hang up on long requests #2936 - axios/axios - GitHub
When you create an HTTP(S) server in node, it sets the socket timeout to 0 (no timeout). Nonetheless, the socket still closed and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found