Why is Springboot server works differently in localhost and heroku host? - java

I want to handle error response. When I use local server I can get error message when exception is hit but when I use the same hosted app It shows response with error message which is null "message":""

I have noticed that when the excptionerror is thrown the server gets stoped a while and the response error comes empty due to network delay. But for local database there is no delay which leads the server to keep responding no matter which response it has

Related

WSO2 API Manager Connection Error , "Error occurred while sending the HEAD request to the given endpoint url"

I'm trying to configure the WSO2 API Manager. (version - v4.0.0)
When I try to create REST API and point to the endpoints I"m getting a Connection error message for the given endpoints. I have hosted the API Manager and the back end services on the same server(backend services are running on the tomcat application on the same server in port 8080)
API Manager Log produces the following message :
ERROR {org.wso2.carbon.apimgt.rest.api.publisher.v1.impl.ApisApiServiceImpl} - Error occurred while sending the HEAD request to the given endpoint url: org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 4000 ms
would really like to what has caused the issue.
P.S: I can access the backend services directly without any connection issues using a REST client.
It's difficult to answer the question without knowing the exact details of your deployment and the backend. But let me try. Here is what I think is happening. As you can clearly see, the error is a connection timeout The host did not accept the connection within timeout of 4000 ms.
Let me explain what happens when you click on the Check Endpoint Status button. When you click on the Check Endpoint Status button, the Browser is not directly sending a request to the Backend to validate it. The Backend URL will be passed to the APIM Server, and the Server will perform the validation by sending an HTTP HEAD request to the BE service.
So there can be two causes. First may be your backend doesn't know how to handle a HEAD request which is preventing it from accepting the request. But given the error indicated it's a network issue, I doubt it even reached the BE.
The second one is, that your Backend is not accessible from the place API Manager is running. If you are running API Manager on Server A and trying to access API Manager via browser from Server B(Local Machine). Although you can access the BE from Server B may be from Server A it's not accessible. When I say BE is not accessible from API Manager server, it means it's not accessible with the same URL that was used in API Manager. It doesn't really matter if it runs in the same Server if you are using a different DNS other than localhost to access it. So go to the server API Manager is running and send a request using the same URL that was used in API Manager and see whether it's accessible from there.
First try doing a curl request by login into the server where APIM is running (not from your local machine). Maybe due to some firewall rules within the server, the hostname given in the URL may not be accessible. Also, try sending a HEAD request as well. You might be able to get some idea why this is happening

Getting "com.mongodb.MongoInternalException: The responseTo in the response does not match the requestId in the request" while connecting to mongodb

My app is using Spring-Boot framework. Everything was working fine until GC overhead error occurred. GC error was recovered but mongodb connection was giving this error continuously after it. But at the same time, other applications which were using same mongodb server was able to connect to it normally. As soon as I restarted my spring-boot app, this error was gone.
Exception was com.mongodb.MongoInternalException: The responseTo (130) in the response does not match the requestId (131) in the request. for every request, responseTo and requestId values were different.
I want to know if this issue was because of OutOfMemoryError? If not, what are the other possible reasons for this error?

How to handle occasional SocketException: Unexpected end of file from server?

I have a REST service that calls another remote service.
Most of the time the communication works fine, but occasionally, I encounter
org.apache.cxf.jaxrs.client.ClientWebApplicationException:
org.apache.cxf.interceptor.Fault: Could not send Message.
org.apache.cxf.interceptor.Fault: Could not send Message.
SocketException invoking https://url: Unexpected end of file from server
I did some research and found it's the remote server shut down the connection unexpectedly.
It really puzzles me, because everything (input, header, etc) is the same and I was testing with a small amount of requests only like (50-100), I have tried both in sequence and in parallel, only a few will encounter this issue.
Why would this happen? Do I have to ask the remote server to reconfigure, or do I have to implement a retry pattern in my service in this case?
Any hint?
Thanks
P.S
I am using
org.apache.cxf.jaxrs.client.WebClient
to invoke the remote service. Will it make any difference if I switch to HttpClient?

which http status codes should I use for command failure in remote machine

I've an API which will take remote machine credentials & commands in JSON, it will execute commands in remote machine by log in with those credentials.
While executing those commands I'm getting exceptions like Auth Failure, connection refused, I should respond to User with above messages.
Questions :
Which Http status code I should use to respond user when above exceptions happened?
How to handle those scenarios?
it is an internal server error hence I suggest to use one of the 500 family, see here for the list of the http status codes.
Usually an http 500 is enought, it's up to you to show or not detailed error information

How to debug tomcat webservice?

I'm running two instances of tomcat on the same machine for 2 parts of a web application(client app and server app). the client has no datastore and uses the server to interact with the database. The server app uses a wsdl web service to listen for GET requests from the client. I get an invalid login everytime I try to login through the client app. If I try to access the LoginService via browser directly I get this error from the catalina logs.
[PhaseInterceptorChain:369] Interceptor for {http://ws.myoscar_server.oscarehr.org/}LoginWsService has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: No such operation: (HTTP GET PATH_INFO: /myoscar_server/LoginService)
I'm not sure what you mean by "everytime i try to login." I think the error you see in the catalina logs is just saying that you are hitting the web service that is listening for only POST requests, but with a browser, you are sending a GET request. That error might be throwing you off. I would first use something like Firefox Poster to send a POST request to your service and see what the real error is.

Categories