504 Gateway Time-out on specific POST request - node.js

Since the discussion forums of Amazon gave an error im posting the question here.
We are running a single nodejs (api) instance with Elastic Beanstalk.
After 4 months of usage, suddenly the POST request for creating users failed with a 504 Gateway Time-out. No modification were made to the code or elastic beanstalk config in the meantime whatsoever.
The rest of the requests are working correctly. When testing locally there are no errors.
In the nginx error log the following occurs:
Upstream timed out (110: Connection timed out) while reading response header from upstream.
Tried Apache as a proxy and this gave a similar error.
Environment
64bit Amazon Linux 2016.03 v2.1.0 running Node.js
Nodejs 4.3.0
Nginx 1.8.1
After trying almost everything we are out of options.
Any suggestions?
Thanks in advance,
Mk

If you're using an ELB, try setting the "Idle Timeout" to a higher time value. You can do this using the AWS CLI:
aws elasticbeanstalk update-environment --environment-name your-env-name --option-settings Namespace=aws:elb:policies,OptionName=ConnectionSettingIdleTimeout,Value=300
I'm not sure if you can do this from the UI but I don't think so.

Related

Localhost to EC2, GET request works but POST request not working AWS

I created a node js app with an express server, after that, I dockerize it and deployed it on AWS ECS, one EC2 instance is also running with good health and in the security group, all traffic is allowed in inbound rules. I have one issue I am sending requests from the frontend to the backend only the GET request works but when I am trying a POST request it didn't work. Below is a screenshot of the Axios error I got when I POST the request -:
I also added a CORS header in the node js backend app -:
Where is the issue can someone guide me? Thanks
This doesn’t look like EC2 issue but mostly your code.
Please have a look at this: Axios sending network error while status is 200 ok

NestJS on EC2 keeps responding with 502 randomly

I made a server with NestJS and ran it on an EC2 instance, and it is responding with 502 randomly.
I googled and a lot of articles mentioned the difference between the timeout interval of ALB and the server.
when I made a simple webpage server with express the same issue happened but fixed it by adjusting keepAliveTimeout and headersTimeout.
(each value was 65000ms and 67000ms)
however, this nestjs server still responds with 502 and I don't know what else to do.
tried to change the timeout of ALB to 30sec and to 120sec and this didn't work either.
what else is the possibility of this issue? I am lost.

499 error code with nginx plesk for nodejs app

I have a nodejs app in a ubuntu server. i use plesk for server management.
I am using a url for catching requets from an external api. It sends a webhook to my url for catching information.
I see in my server log, 499 error when this url is requested.
I cannot find any nginx configuration for fixing this problem
Any ideas?
Kind regards
I had similar issues with NGINX recently.
The reason was server timeout - NGINX forwarded request to a backend service (Spring in my case), the backend service timed out.
In my case it was due to "out of memory" exc in Spring Boot app.
So, most probably it's an issue in your node service.

AWS ElasticBeanstalk + Socket.IO + SSL issue

I'm having trouble working with AWS ElasticBeanstalk with NodeJS environment + Socket.IO + SSL for our messaging app.
I'm already running in circles trying to fix the issue but I always ends up to a Websocket handshake error (504 GATEWAY_TIMEOUT).
AWS Elastic Beanstalk Load Balancer configuration:
ELB security inbound rule
Instance's security inbound rule
Response error
Front end code
Thanks in advance. Any help is highly appreciated!
Finally!!! Got it!
So after a lot of hours burned, this solution works for me.
The problem is that I have HTTPS in my load balancer pointed to HTTP on my ec2 instance. That causes a problem because websocket runs on TCP and not HTTP/S. The port number also did matter in my case.
Original config (not-working)
New config (working)
I hope this can be of any help in the future. :-)

Socket.io - invalid HTTP status code on SOME browsers

Just after a few weeks of working fine, our Socket.io started spewing errors on some browsers. I've tried updated to the latest Socket.io version, I've tried our setup on different machines, I've tried all sorts of machines, it seems to work on most browsers with no clear pattern of which work.
These errors appear on a second interval:
OPTIONS https://website.com/socket.io/?EIO=2&transport=polling&t=1409760272713-52&sid=Dkp1cq0lpKV75IO8AdA3 socket.io-1.0.6.js:2
XMLHttpRequest cannot load https://website.com/socket.io/?EIO=2&transport=polling&t=1409760272713-52&sid=Dkp1cq0lpKV75IO8AdA3. Invalid HTTP status code 400
We're behind Amazon's ELB, Socket.io on polling because the ELB router doesn't support WebSockets.
I found the problem that has been causing this, and it's is really unexpected...
This problem comes from using load balanced services like AWS ELB (independent EC2 should be fine though) and Heroku, their infrastructure doesn't support Socket.io features fully. AWS ELB flat out won't support WebSockets, and Heroku's router is trash for Socket.io, even in conjunction with socket.io-redis.
The problem is hidden when you use a single server, but as soon you start clustering, you will get issues. A single Heroku dyno on my application worked fine, and then the problems started appearing in production out of development, when we weren't using more than one server. We tried on ELB with sticky-load balance and even then, we still had the same issues.
When socket.io returns 400 errors, in this case it was saying "This session doesn't exist and you never completed the handshake", because you completed the handshake on a different server in your cluster.
The solution for me was just dedicating an EC2 instance for my web app to handle Socket.io.

Resources