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.

AWS Lambda timing out due to open socket.

See original GitHub issue

We are currently using your library in some of our AWS Lambda functions.

The way we use it is as a Stream in our bunyan logger. Even though everything seems to be working fine, and the logs reach our backend log aggregator servers, the Lambdas keep timing ou 100% of the time.

setting

context.callbackWaitsForEmptyEventLoop = false

seems to help to get rid of the timeouts, however the logs stop being sent to the backend.

We haven’t nailed down the issue 100% but it seems very likely that the timeouts are happening because of your library leaving connections/sockets open.

Can someone please advise?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
okkezcommented, Feb 27, 2018

Are we sure that all the messages will be sent if we close the sender like that?

Yes. We can wait ack response from Fluentd with requireAckResponse: true option.

'use strict';
const Console = require('console').Console;
var sender = require('fluent-logger').createFluentSender('tag.prefix', {
  host: 'localhost',
  port: 24224,
  timeout: 3.0,
  reconnectInterval: 600000, // 10 minutes
  requireAckResponse: true
});
var stdout = sender.toStream('stdout');
var stderr = sender.toStream('stderr');
var logger = new Console(stdout, stderr);
logger.log('this log record is sent to fluent daemon');
sender.end('end', {"message": "end of message!!"});

sender.end() w/o parameters will close socket immediately.

0reactions
okkezcommented, Feb 27, 2018

#91 is relevant to this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot Lambda function retry and timeout issues ... - AWS
There are three reasons why retry and timeout issues occur when invoking a Lambda function with an AWS SDK:.
Read more >
AWS lambda Java open http socket times out - Stack Overflow
There is nothing in the role or permission-related to sockets. Don't be so sure it isn't the site -- the source address will...
Read more >
preauthentication invocation failed due to error socket timeout ...
Verify that your Lambda function is timing out. Retrieve the request IDs of any timed-out invocations by searching the function's Amazon CloudWatch log...
Read more >
AWS Lambda Timeout Best Practices - Lumigo
If you work on a serverless project, you have probably run into the issue of AWS Lambda timeouts handling. Lambda functions are short...
Read more >
How to overcome API Gateway timeouts using WebSocket
A how-to guide on integrating WebSocket into a Serverless Framework based AWS Lambda backend. A while ago, one of our clients asked us...
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