i setting data feeds external website , code given below working on dev, qa environments. failing in production. 1 thing noticed writetolog in authenticator not getting displayed on console in production environment whereas in dev , qa working. because of missing library.
i running on java 1.8. have tried approach of using system.setproperties set variables https.proxyhost, proxyport, proxyset, user , password. didn't work either. wget , curl command working on production after setting https_proxy environment variable.
try { proxy proxyname = new proxy(proxy.type.http, new inetsocketaddress(proxyhostname, proxyportnum)); authenticator credentials = new authenticator() { @override protected passwordauthentication getpasswordauthentication() { writetolog.info(proxyuserid + proxyuserkey.tochararray()); return (new passwordauthentication(proxyuserid, proxyuserkey.tochararray())); } }; authenticator.setdefault(credentials); dataconnection = (httpsurlconnection) requesturl.openconnection(proxyname); string uname_pwd = proxyuserid + ":" + proxyuserkey; string authstring = "basic " + new sun.misc.base64encoder().encode(uname_pwd.getbytes()); writetolog.info(authstring); dataconnection.setrequestproperty("proxy-authorization",authstring); writetolog.info(dataconnection.getrequestmethod()); return dataconnection.getinputstream(); } catch (ioexception ex) { writetolog.error("httpsconnectionreturnstream():",ex); throw ex; }
error message is:
javax.net.ssl.sslhandshakeexception: remote host closed connection during handshake @ sun.security.ssl.sslsocketimpl.readrecord(sslsocketimpl.java:992) @ sun.security.ssl.sslsocketimpl.performinitialhandshake(sslsocketimpl.java:1375) @ sun.security.ssl.sslsocketimpl.starthandshake(sslsocketimpl.java:1403) @ sun.security.ssl.sslsocketimpl.starthandshake(sslsocketimpl.java:1387) @ sun.net.www.protocol.https.httpsclient.afterconnect(httpsclient.java:563) @ sun.net.www.protocol.https.abstractdelegatehttpsurlconnection.connect(abstractdelegatehttpsurlconnection.java:185) @ sun.net.www.protocol.http.httpurlconnection.getinputstream0(httpurlconnection.java:1512) @ sun.net.www.protocol.http.httpurlconnection.getinputstream(httpurlconnection.java:1440) @ java.net.httpurlconnection.getresponsecode(httpurlconnection.java:480) @ sun.net.www.protocol.https.httpsurlconnectionimpl.getresponsecode(httpsurlconnectionimpl.java:338) @ com.project.fetch.webapireader.httpsconnectionreturnstream(webapireader.java:186) @ com.project.fetch.webapireader.webapirequesttokensubmit(webapireader.java:200) @ com.project.run.launchapplication.launchoperation(launchapplication.java:50) @ com.project.run.launchapplication.main(launchapplication.java:35) caused by: java.io.eofexception: ssl peer shut down incorrectly @ sun.security.ssl.inputrecord.read(inputrecord.java:505) @ sun.security.ssl.sslsocketimpl.readrecord(sslsocketimpl.java:973) ... 13 more
when adding system.setproperty("javax.net.debug","ssl,handshake") additional information:
main, write: tlsv1.2 handshake, length = 277 main, received eofexception: error main, handling exception: javax.net.ssl.sslhandshakeexception: remote host closed connection during handshake main, send tlsv1.2 alert: fatal, description = handshake_failure
can me in figuring out how debug or solve problem ? compared security certificates on qa , prod returned debug message. matching. tried changing https.protocol tlsv1 well. not working.
i tried hardcoding ip address instead of qualified hostname proxy server. code worked fine after that. not sure why jvm isn't able resolve hostname when works command line using ping, wget or curl.
Comments
Post a Comment