0

Actionhero server sometimes receives 502 errors. The actionhero server is configured as AWS ECS and is called AWS ALB.

I'm looking for a way to set up the headersTimeout, because i heard it can prevent errors in 502.

how to set keepAliveTimeout and headersTimeout in actionherojs?

Or, is there a way to avoid 502 error when calling aws alb?

in express.js example

const server = app.listen(port);
server.keepAliveTimeout = time;
server.headersTimeout = time;

1 Answers1

0
  • It would be nice if the question was more specific.

See the official reference.

https://www.actionherojs.com/tutorials/web-server
https://www.actionherojs.com/tutorials/websocket-server

        // websocket Server Options:
        server: {
          // authorization: null,
          // pathname:      '/primus',
          // parser:        'JSON',
          // transformer:   'websockets',
          // plugin:        {},
          // timeout:       35000,
          // origins:       '*',
          // methods:       ['GET','HEAD','PUT','POST','DELETE','OPTIONS'],
          // credentials:   true,
          // maxAge:        '30 days',
          // exposed:       false,
        },

In the case of websocket server timeout exists, but there is no option in web-server.

If you want the process(server) to run only for a set amount of time, see below

const cp = require('child_process')
const path = require('path')

// Create the child
let child = cp.fork(path.join(__dirname, './actionhero.js'), [])

// Kill after "x" milliseconds
setTimeout((x) => {
  child.kill()
}, x);

AWS 502 Error in load balancer ref : https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-troubleshooting.html

HTTP 502: Bad gateway Possible causes:

The load balancer received a TCP RST from the target when attempting to establish a connection.

  • The load balancer received an unexpected response from the target, such as "ICMP Destination unreachable (Host unreachable)", when attempting to establish a connection. Check whether traffic is allowed from the load balancer subnets to the targets on the target port.

  • The target closed the connection with a TCP RST or a TCP FIN while the load balancer had an outstanding request to the target. Check whether the keep-alive duration of the target is shorter than the idle timeout value of the load balancer.

  • The target response is malformed or contains HTTP headers that are not valid.

  • The load balancer encountered an SSL handshake error or SSL handshake timeout (10 seconds) when connecting to a target.

  • The deregistration delay period elapsed for a request being handled by a target that was deregistered. Increase the delay period so that lengthy operations can complete.

  • The target is a Lambda function and the response body exceeds 1 MB.

  • The target is a Lambda function that did not respond before its configured timeout was reached.

myeongkil kim
  • 2,465
  • 4
  • 16
  • 22
  • 음.. 지금 문제가 aws alb 에서 액션히어로 호출시 502 에러가 발생되고있어서요. headersTimeout 을 설정할경우 응답을 주어 502 에러를 막을수 있다고 하여 설정방법을 찾고있습니다. 아래는 참고한 블로그 입니다. https://adamcrowder.net/posts/node-express-api-and-aws-alb-502/ – sang kwon seo Dec 08 '20 at 08:13
  • and, due to the nature of the community, please write in English. – myeongkil kim Dec 08 '20 at 08:29
  • The problem is Application Load Balancer, not Classic Load Balancer. I checked the AWS document. and.. thank you for your advice. – sang kwon seo Dec 08 '20 at 08:44