-
Notifications
You must be signed in to change notification settings - Fork 2.6k
made websocket client use java.net instead of java.nio #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.