Hi i have a Spring Rest Webservice deployed in the weblogic service. I have advance rest client of google chrome which work perfectly over https I am trying to create to Client over https Client. I have ca certificate and client certificate. I created it from the below link Accessing secure restful web services using jersey client But i am getting exception below
Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection timed out: connect
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:155)
at com.sun.jersey.api.client.Client.handle(Client.java:652)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570)
at org.app.last.JerseyClient.get_JSON(JerseyClient.java:39)
at org.app.last.JerseyClient.main(JerseyClient.java:239)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:564)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:141)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:395)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:530)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:272)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:329)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:172)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:158)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:253)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:153)
... 6 more
It seems like you still have a problem with the proxy. and also you can have problem with the certificate
Check your firewall settings to see if the outbound ports are blocked except for the browser. This happens occasionally depending on the company.
Outbound ports are by default opened, but this might have been changed by system administrators - see this answer.
Also the connection might be blocked at the level of your corporate proxy. For example in some companies you can only surf with one browser, and if you install and try to access the internet with another browser, you receive a message "It's only allowed to browser the internet with browser XX", or a timeout.
This works because the proxy checks for the User-Agent header.
Many proxies require authentication and only give access to authorized users. Chrome fils in your credentials automatically in some HTTP header while surfing, but your program does not do that.
To troubleshoot this, try the following possibilities:
print the Url to the console with System.out.println
and confirm that it's exactly the same as you type in Chrome
use a non-browser based command line utility like curl or wget to check if you can access for example google and also the endpoint
check your firewall settings
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With