What is the correct status code, if my server can't reach a third party server? - http

I have a server, which does a request to AWS S3.
What is the correct status code, if my server's request to S3 failed?
Let me break it down more.
"Client" does request to "my server".
"My server" does a request to a "third party server", which fails.
Now "my server" needs to communicate to the "client", that the client's request failed because the request to the third party server failed.
I googled and found that 502 Bad Gateway, might be correct here, but I'm not sure because it also talks about my server being a proxy, which it isn't. My server does additional processing and database calls with the content of the request before the call to AWS S3, as well as after it got the result from AWS.

Related

How to distinguish between proxy and endpoint as source of connection timeout?

When I try to connect to a server (website) through a proxy, sometimes I get "Connect timeout" errors. How can I determine whether the failed connection was to the proxy or to the endpoint? I don't have access to logs on the proxy or endpoint.
My use case is evaluating proxies by accessing a proxy judge web page. It may be that the judge is overloaded. Or it may be that the proxy no longer works. If the judge is overloaded I want to back off, if the proxy is broken, I want to stop using it.
perl -MNet::HTTP -e 'Net::HTTP->new( Host => "HOSTNAME:PORT", Timeout => 5 ) && print "OK\n"'
This issues a CONNECT to the server at HOSTNAME:PORT and prints OK if the CONNECT succeeds.

what's mean "the request cannot be passed to the next server if nginx already started sending the request body"

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_request_buffering
i can not understanding "When buffering is disabled, the request body is sent to the proxied server immediately as it is received. In this case, the request cannot be passed to the next server if nginx already started sending the request body."
what's mean "the request cannot be passed to the next server if nginx already started sending the request body"
If you have a service with multiple upstream servers, possibly for load balancing or resilience, and one of the upstream servers fail while Nginx is sending the request body to it, Nginx may try to use another server.
But it can only try another server if it has a complete copy of the original request body (i.e. request buffering enabled) or the client has not started sending the request body yet.

openresty on body_filter_by_lua send socket

I have a demand, is at server return response, send a request to other server, but openresty say API disabled in the context of body_filter_by_lua*. i use module resty.http.
thanks
You can change the main logic.
First issue subrequest to your upstream (location.capture or lua-resty-http)
Upon success you may first send the response downstream by Lua code and issue the next subrequest to your "other server" from Lua.
UPDATE - this doesn't work
As second approach you may treat your "other server" as upstream and allow request to this upstream only if subrequest to original server will be successful.
For both scenarios you may use access_by_lua* and content_by_lua* where cosocket API is available.

How to connect DataSnap client to DataSnap server via proxy server?

The problem is this:
I decided to make a messenger/chat (VCL application) with callback on DataSnap technology (IDE Delphi XE6), has created a simple DataSnap server (tcp / ip + http) without the database, and thick client.
All works fine if the whole thing run on a local network (tcp / ip) or via the Internet (http).Problems arise when run over HTTP and the client machine has a HTTP proxy server, the client application can not connect to my DataSnap server application. Client application gets error "10061 connection refused"
or "Expected datasnap context in request http://[YourServerIP]:[YourPort]/datasnap/tunnel".
I tried to enter IP and port of the proxy server to params of component TSQLConnection.Driver params DSProxyHost and DSProxyPort, turned off my firewall and antivirus software, checked allows traffic to the proxy ip + port, but the problem has not disappeared.
After few days searches, without results, i decided listening requests from client application and response of my DataSnap Server application in HTTPTrace procedure of DSHTTPService1 component, also with software HTTPDebugerPro, and i noticed interesting thing:
when client app connecting to ds server app without proxy server, in request ds server app receive URI with this text "/datasnap/tunnel" and all works fine ds server response "200, OK".
when client app connecting to ds server app with proxy, in request ds server app receive URI with text "http://[YourServerIP]:[YourPort]/datasnap/tunnel" and raised exception with response error "404, Expected datasnap context in request http://YourServerIP:YourPort/datasnap/tunnel".
Has anyone knows solution about this problem? How to connect DataSnap client to DataSnap server via proxy server? I searched solution for this problem several days, I shoveled the Internet but have not yet found a solution.

Use JMeter HTTP Proxy to record JSON over HTTP request from not-a-browser client

I have a client program running locally in iPhone emulator and local server written in Java. Client talks to server with JSON over HTTP requests. Now I am trying to record a client session http requests with JMeter to use them as a base to load-test server.
The problem is client requests do not go throw JMeter proxy. Client gets 501 "Method not implemented" (it is not because of https, I am using http). There is nothing in JMeter log about the request, and obviously nothing gets recorded in JMeter and the request doesn't reach the server.
There is well-described steps to setup JMeter proxy to record request from a browser, but my client programm is not a browser. Though JSON over HTTP is widely adopted approach, I could not find anything on the web about recording such requests with JMeter. I understand I need to do on the client the same thing browser does when proxying request and what I've found about it is that I need to set Host header to server's host and port, but that did not work and I cannot see how is it related to 501 error client gets.
If someone can explain what should be done on client or how to configure JMeter to let it know where to proxy client's requests or link any manual explaining that, it would be great help. I've been searching for solution for a few hours already and had no luck. Please help.
You can see my question and the answer I got below:
Use Jmeter proxy to record HTTP calls from iOS simulator
In short:
With this tutorial you can record calls from your Android device:
http://blazemeter.com/blog/load-testing-mobile-apps-made-easy
For make same thing with iPhone, do the following steps:
Mac configuration:
system preferences -> Network -> Advanced.. -> Proxies -> check "Web Proxy (HTTP) ->in "Web Proxy Server" field, type your IP (http://www.wikihow.com/Find-Your-IP-Address-on-a-Mac), and choose available port (I using 8080) ->ok -> Apply
iPhone configuration:
Settings -> WiFi -> choose same wifi you use with your Mac -> press on it again to go to it's details -> scroll down ->In HTTP proxy, choose Manual -> server = your mac IP you found earlier -> port = the port you chosen (maybe 8080)
Now You can start recording all "iPhone network out" using jmeter recording controller

Resources