HTTP gateway timeout - http

When I tried to request the data across the internet through a web service I received an error as:
Error: The request failed with HTTP status 504: Gateway Time-out.
Can anyone please give an insight about this error, and a solution too? Thanks in advance.

There is some proxy (reverse proxy, HTTP server with FastCGI or something similar) in the way, which timeouted when getting request from the server.

Related

Jmeter- Nginx-Non HTTP response code: org.apache.http.conn.HttpHostConnectException/Non HTTP response message: Connection timed out: connect

Im executing a load testing using Jmeter. Sometimes I get the error "Non HTTP response code: org.apache.http.conn.HttpHostConnectException/Non HTTP response message: Connect to example.com failed: Connection timed out: connect" even for 100 users. But sometimes it passes 5000 users without any errors. Im unable to find out where exactly is the issue, if its on Nginx webserver or at the network end.
In the nginx configuration, I have added keepalive, keepalive_requests, keepalive_timeout in the upstream module part. Kindly help me with a solution on how to fix this issue and any suggestions to optimize the server configuration.

What happens to http request for which client timed out?

I believe I understood http client connection timeout vs server request timeout and this SO answer did a pretty good job in explaining same.
However what I couldn't found anywhere is what happens to http request received by server but client timed out. Basically what http status code I should be logging for such requests ?

What status code should I return for a connection error?

I'm writing a service that returns data about another request to the consumer (for example, retrieving the un-shortened URL from a bitly or t.co address). In most situations, I can return a status code to mirror the code I received from the server, but what status code is most appropriate when my service is unable to connect to the requested URL (if it doesn't exist, for example)? I was thinking 400 Bad Request or 408 Request Timeout, but is there a best practice here?
503 Service Unavailable seems like an appropriate choice. The 4xx codes are meant to indicate the client did something wrong. In the case you specify, it's a service error.
502 Bad Gateway, since you're acting as a proxy server.
The HyperText Transfer Protocol (HTTP) 502 Bad Gateway server error response code indicates that the server, while acting as a gateway or proxy, received an invalid response from the upstream server.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502
Interesting and debatable. What if the IP(hostname) is unavailable temporarily? 503 is more accurate in that sense. If at all someone is trying to connect to an IP(hostname) that doesn't exists (which is beyond the realms of gateway to determine) a bad gateway may look appropriate.
However 504 could be more realistic as to convey what system has attempted and that would convey a timeout and not received any response from the upstream.

amazon load balancer returns error code 400

We have a load balancer on amazon which balance 4 servers.
When sending specific HTTP request to the load balancer I get Http error code 400.
But when I sends the same request to each one of the servers directly I get Http 200 OK.
Other requests are working fine when using the balancer.
Any Ideas?
Thanks.
Don't know if this will help you, but I've had a similar problem. I was using jMeter and when accessing my instance over AWS load balancer I would always get: HTTP/1.1 400 BAD_REQUEST.
After lot of debugging I found out that I was sending an empty header (no name and no value) because I had an empty row in HTTP Header Manager in jMeter. So, I persume, AWS ELB does some headers checking, and returns HTTP 400, even tough I wasn't having any problems with going with the same request to my instances directly. I don't know if this will help you but you should double-check your headers for some stupid mistake like this one :D
I had a similar problem to this, and it was caused by ALB not accepting HTTP methods that are in lower case.
GET http://myhost.com/foo -> HTTP 200
get http://myhost.com/foo -> HTTP 400
In my case it was the headers issue.
ELB-HealthChecker was sending healthcheck request to my web server and nginx replied with 400.
The issue was that ELB-HealthChecker sends no headers with the request.
Depending on the configuration of your webserver, this might return 400 error code.
To check if this is the case, replicate "no headers" request with curl:
curl -I -H 'User-Agent:' -H 'Accept:' -H 'Host:' http://yourservice/health/
The solution is to configure nginx endpoint that will return 200 regardless of the presence of the request headers:
location = /health/ { return 200; }
In my case my target group for Port 443 was using HTTP protocol instead of HTTPs and I was getting 'Client using HTTP to connect to HTTPS server'

Connect to external HTTP server from Netty

I need some help with understanding how to write HTTP router, which recognizes HTTP header as routing criteria. I found the link https://github.com/cgbystrom/netty-tools/blob/master/src/main/java/se/cgbystrom/netty/http/router/RouterHandler.java which seems to do the routing itself. But now it is not clear, how to
connect to another HTTP server
send HTTP request
wait for HTTP response
forward the HTTP response to client
can somebody please give me some explanations?
http://static.netty.io/3.5/xref/org/jboss/netty/example/proxy/package-summary.html
the example of proxy server in Netty, essentially what I wanted

Resources