made websocket client use java.net instead of java.nio#205
made websocket client use java.net instead of java.nio#205Davidiusdadi merged 10 commits intoTooTallNate:masterfrom
Conversation
…TallNate#88, TooTallNate#155, TooTallNate#167, TooTallNate#175, TooTallNate#177, TooTallNate#187) (changes not yet fully tested)
…ting the problem
|
@Davidiusdadi do you know when this one will get merged? Thank you. |
waiting for clients to close connection first
made websocket client use java.net instead of java.nio
|
Hi, the changes in master allowed us to do WSS through a http-proxy with Connect. Sample code: public static void main( String[] args ) throws Exception {
URI serverUri = new URI( "wss://ourapp.herokuapp.com:443/ws1" );
WebSocketChatClient chatclient = new WebSocketChatClient( serverUri );
Proxy proxy = new Proxy( Proxy.Type.HTTP, new InetSocketAddress( "proxy.corporate.com", 2128) );
Socket proxySocket = new Socket(proxy);
String host = serverUri.getHost();
int port = serverUri.getPort();
proxySocket.connect(new InetSocketAddress(host, port));
SSLContext sslContext = null;
sslContext = SSLContext.getInstance( "TLS" );
sslContext.init( null, null, null );
SSLSocketFactory factory = sslContext.getSocketFactory();
chatclient.setSocket( factory.createSocket(proxySocket, host, port, true) );
chatclient.connectBlocking();
BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
while ( true ) {
String line = reader.readLine();
if( line.equals( "close" ) ) {
chatclient.close();
} else {
chatclient.send("{\"msg\":\"" + line + "\"}");
}
}
}This wasn't possible in the previous 1.3.0 release. Would you consider a new release incorporating these changes? |
|
RE: @shuckc's comment, anyone know if it works for Android or just in (desktop) Java? For Java, there seems to be a platform limitation that was fixed a while back (in Java 8?). But not aware of anything similar for Android, there's no mention of the issue or whether there is or isn't HTTP proxy support for sockets in Android. Just asking as it seems we've encountered the mentioned Java limitation error using this library with HTTP proxy specified on Android. I guess for Android, one has to refer to #672. |
These changes should help to resolve:
#88, #155, #167, #175, #177, #187
I tested briefly on my local machine but before merging further testing has to be done.