I am trying to access websockets from the proxy in my work place( it is mandatory to use this proxy in my workplace), but I am not able to connect to Websockets. I am able to connect to KiteConnect and I am also able to get Quotes and I am also able to access KIte Web trading application from the same proxy but when I connect to websockets I am getting the below exception.
java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:656) at sun.security.ssl.SSLSocketImpl.(SSLSocketImpl.java:415) at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88) at com.neovisionaries.ws.client.WebSocketFactory.createDirectRawSocket(WebSocketFactory.java:449) at com.neovisionaries.ws.client.WebSocketFactory.createRawSocket(WebSocketFactory.java:380) at com.neovisionaries.ws.client.WebSocketFactory.createSocket(WebSocketFactory.java:312) at com.neovisionaries.ws.client.WebSocketFactory.createSocket(WebSocketFactory.java:292) at com.neovisionaries.ws.client.WebSocketFactory.createSocket(WebSocketFactory.java:182) at com.rainmatter.ticker.KiteTicker.connect(KiteTicker.java:110) at com.custom.service.FetchKiteConnectDataService.tickerUsage(FetchKiteConnectDataService.java:235) at com.custom.service.FetchKiteConnectDataService.main(FetchKiteConnectDataService.java:90)
Hi @Kulbir, Kite web uses same Kite ticker as API users, if Kite Web is working fine then I would suggest you to check your code/configuration, change proxy or contact your network admin.
There is no issue with myCode, as I am using the official Java Kite Connect client( without any modifications). By the way I debugged and found that in the following method, the proxy is not being set and instead of calling createProxiedRawSocket() it is calling createDirectRawSocket() :
com.neovisionaries.ws.client.WebSocketFactory private Socket createRawSocket(String host, int port, boolean secure){ }
This looks like a bug for your JAVA Client, what do you think ? At the code level can I pass some check to setProxy or bypass Proxy ?
Is there a technical person involved in this discussion forum of Kite Connect who can help with this issue. If yes then please forward my request to him, your help will be really appreciated.
Hi @Kulbir, I am technical person. Problem with proxy is that we will not be able to figure out what is the network configuration set by your network admin, firewall properties and other details. I am afraid we can't help you with it.
I am extremely sorry , I was not aware you were a technical person. Coming back to the point of the proxy, I agree that you cannot help me behind the proxy.
Even without the proxy sometimes the websockets work and sometimes I get the following SSL Handshake exception :
com.neovisionaries.ws.client.WebSocketException: Failed to send an opening handshake request to the server. at com.neovisionaries.ws.client.WebSocket.writeHandshake(WebSocket.java:1604) at com.neovisionaries.ws.client.WebSocket.shakeHands(WebSocket.java:1510) at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:824) at com.rainmatter.ticker.KiteTicker.connect(KiteTicker.java:158) at com.custom.service.FetchKiteConnectDataService.tickerUsage(FetchKiteConnectDataService.java:228) at com.custom.service.FetchKiteConnectDataService.main(FetchKiteConnectDataService.java:84) Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1937)
Can you please help and maybe you or someone from KiteConnect team can provide me some info on what parameters I will need to create a Proxied Connection. If you can let me know the parameters needed then I can get them and make the connection at my end.
Hi @Kulbir, Proxy issues are arbitrary, it depends on user's network, proxy and firewall configuration. We can't help users with this. You have to do deal with trial and errors to arrive at right solution.
Kite web uses same Kite ticker as API users, if Kite Web is working fine then I would suggest you to check your code/configuration, change proxy or contact your network admin.
There is no issue with myCode, as I am using the official Java Kite Connect client( without any modifications). By the way I debugged and found that in the following method, the proxy is not being set and instead of calling createProxiedRawSocket() it is calling createDirectRawSocket() :
com.neovisionaries.ws.client.WebSocketFactory
private Socket createRawSocket(String host, int port, boolean secure){
}
This looks like a bug for your JAVA Client, what do you think ? At the code level can I pass some check to setProxy or bypass Proxy ?
It is open source, you can clone repository, make modifications and use it.
Is there a technical person involved in this discussion forum of Kite Connect who can help with this issue. If yes then please forward my request to him, your help will be really appreciated.
Regards
Kulbir
I am technical person. Problem with proxy is that we will not be able to figure out what is the network configuration set by your network admin, firewall properties and other details. I am afraid we can't help you with it.
I am extremely sorry , I was not aware you were a technical person.
Coming back to the point of the proxy, I agree that you cannot help me behind the proxy.
Even without the proxy sometimes the websockets work and sometimes I get the following SSL Handshake exception :
com.neovisionaries.ws.client.WebSocketException: Failed to send an opening handshake request to the server.
at com.neovisionaries.ws.client.WebSocket.writeHandshake(WebSocket.java:1604)
at com.neovisionaries.ws.client.WebSocket.shakeHands(WebSocket.java:1510)
at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:824)
at com.rainmatter.ticker.KiteTicker.connect(KiteTicker.java:158)
at com.custom.service.FetchKiteConnectDataService.tickerUsage(FetchKiteConnectDataService.java:228)
at com.custom.service.FetchKiteConnectDataService.main(FetchKiteConnectDataService.java:84)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1937)
Can you please help with this, I am really stuck.
Regards
Kulbir
Check out this post.
I found a way to make a Proxied Socket instead of a normal socket.
Inside KiteTicker.java, I am trying to use the following piece of code :
WebSocketFactory wsFactory = new WebSocketFactory();
ProxySettings mProxySettings = wsFactory.getProxySettings();
mProxySettings.setHost(****************);
mProxySettings.setSecure(true);
mProxySettings.setCredentials(******, ******);
ws = wsFactory.createSocket(wsuri);
ws.addListener(new WebSocketAdapter()
Can you please help and maybe you or someone from KiteConnect team can provide me some info on what parameters I will need to create a Proxied Connection. If you can let me know the parameters needed then I can get them and make the connection at my end.
Regards
Kulbir
http://stackoverflow.com/questions/29430503/java-websocket-with-proxy
Clone javakiteconnect and modify this class to set proxy as mentioned in above SO thread and use it as your library.
I was doing exactly that, hope this works, have you or the kite connect team dealt with a proxy connection issue like this before ?
Regards
KULBIR
We don't use proxy.
What i meant was proxy issue with some other user trying to connect to kite connect with websockets.
Kulbir
Proxy issues are arbitrary, it depends on user's network, proxy and firewall configuration. We can't help users with this. You have to do deal with trial and errors to arrive at right solution.
Thanks for your inputs. I think i will have to figure it out on my own. I think you may close this discussion
Kulbir