"500 Internal Server Error" returned when sending GET request using HTTP Client in idea - spring-boot

I am trying to test a Spring Boot project using HTTP Client of IDEA to send a GET request, but it return "500 Internal Server Error":
But under the same conditions, it is no problem to send by browser:
There's no problem using postman:
But using postwoman will cause a CORS problem. By default, postwoman run on port 3000, so I add #CrossOrigin(value = "http://localhost:3000") on the controller class. After that, there was no problem with the test:
At the same time, there is no problem sending GET request using VSCode's REST Client plug-in:
The controller class code is as follows:
It's confirmed that it's not a firewall problem, so is this a bug of HTTP Client?
Or does the HTTP client need to set some configuration?

It's a proxy problem. It is HTTP proxy set in IDEA. 500 is returned by the proxy server.

Related

How can I forward server response error to client with Jetty proxyservlet.Transparent?

I have implemented a proxy extending jetty's ProxyServlet.Transparent.
However upon testing I noticed there is a difference on error messages the user sees when the server returns an error.
For example, when connecting directly to one of our application server with an invalid user credential, the server should return something more specific with instructions on the auth as we have set it this way. When connecting to the proxy server the error is in its most generic form like Authentication failed: Unauthorized
I suspect at some stage jetty checks on the server response and set the proxy response with minimal information so I am looking into the Transparent class code and its parent classes to find which method I can override to intercept the original server response and forward the information in the proxy response, assuming my understanding on these two responses are correct.
Thanks for the help.

JMeter response 504 Gateway time-out?

I am trying to perform a test against an endpoint with 1 thread. I configured a HTTP request with JSON Monk endpoint URL using JMEter.
But when I run the test I get Response code:504 in the Sampler result. The same when I use the URL in a browser I get also 504 Gateway Time-out
Can anyone help me with this issue? - I tried in another pc and I got the same error!
I have installed JMeter correctly and my code is correct too. I am working on a Windows 10.
HTTP Request:
As per HTTP Status Code 504 description
The HyperText Transfer Protocol (HTTP) 504 Gateway Timeout server error response code indicates that the server, while acting as a gateway or proxy, did not get a response in time from the upstream server that it needed in order to complete the request.
Note: A Gateway might refer to different things in networking and a 504 error is usually not something you can fix, but requires a fix by the web server or the proxies you are trying to get access through.
So it indicates the problem with the server you're trying to test, if you own the website - go and fix it, if you know someone who is responsible for it - inform him/her/them.
There is nothing you can do from JMeter perspective. If you know how response should look like you can use a Dummy Sampler to return this response so you could play with the response data
By the way, it's down for me as well:

Postman 503 Service Unavailable

I tried using postman to test my springboot project. When I sent the request, postman made a 503 error, but when I sent the request in the browser, it successfully got a response.
How to solve this problem?
I had the same issue I resolved it like this :
Postman settings
go to the top right of your postman window Settings > proxy > use the system proxy
for my case I added another proxy so I had to desable it when making a local api call. good luck !
503 Service Unavailable clearly states the server is overloaded, you may be running out of memory. Try again or try to restart the server. The post method will say bad request only. So you should try restarting the server if it is yours, or retry after sometime if it is a 3rd party service.
And also can you check and make sure your postman proxy is turned off. Even that causes problems like these sometimes. Check that in proxy tab.

JMeter error : java.net.SocketException: Unexpected end of file from server

I have read and tried the solutions shared in the previous posts for this error but nothing helped me to fix this. Kindly help.
I am making a HTTPS API call. A very simple call which accepts a 2 KB JSON message via POST method and sends a one word acknowledgement. It works perfectly fine in Postman tool. In JMeter, no. of threads (users) is kept as 25. It works perfectly fine one time with all 25 success response and at times getting few failure response as
Response code: Non HTTP response code: java.net.SocketException
Response message: Non HTTP response message: Unexpected end of file from server
No consistency at all. I have also tried with both enabling and disabling "use keepalive" checkbox. Both giving me all success one time ; few/all failure at another time with the above error. Please help. Thank you.
Below are the JMeter settings:
HTTP Header Manager : Content-Type - application/json
HTTPRequest sampler : protocol - HTTPS
Server Name or IP : project server name
Method : POST
PATH : The required path with https authentication details passed as parameters
IMPLEMENTATION : Set to JAVA (HTTPCLIENT4 was giving me “443 failed to respond” error)
Add header
Connection Keep-Alive
Both errors (Java implementation and Apache HTTPClient4 implementation), are essentially saying the same thing: The server closed the connection, without providing any response. I think there could be the following reasons:
Authentication problem. If server side checks authentication before processing a request (e.g. using Spring), it may be rejecting your request, it may be not bothering with any response if authentication is not considered correct.
Request Issue. Some less noticeable properties of the request you send via Jmeter are different from what you send in Postman. It could be some minor thing with formatting, or some headers server expects. Some of such inconsistencies can also cause Load Balancer (if you use one) to reject request before it's delivered to the server.
Certificate issues. Since you are using HTTPS, you need to make sure your certificate is setup correctly on JMeter side.
So I suggest:
Review server logs and see if your request makes it to the server. If yes, you might be able to see how it was rejected. If not, you need to trace back and see who rejected it (LB, authentication, etc)
Compare headers and body sent by JMeter vs Postman line to line (use TCPDump for example to obtain it).

Jmeter default windows authentication

I have an application which automatically login using my windows domain credentials. I tried with the below in Jmeter.
HTTP Request
HTTP Header manager(Authorization with Basic encoded string)
I am getting below response
Response code: 500
Response message: Internal Server Error
I was able to view content on browser. I tried the same with java code as below
CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
Authenticator.setDefault(new MyAuthenticator("username", "password"));
URL url = new URL("http://someurl");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
System.out.println(connection.getResponseCode());
System.out.println(connection.getResponseMessage());
This gives me 200 OK response.
Please let me know how to achieve this through Jmeter. Thanks in advance!
Try adding HTTP Authorization Manager in your jmeter test suite and enter your credentials there.This will likely solve your problem

Resources