Skip to content

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

Merged
merged 10 commits into from
Sep 23, 2013

Conversation

Davidiusdadi
Copy link
Collaborator

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.

  • The default java proxy's can now be used
  • ssl should no longer make trouble on android
  • the code is simpler

@mkuklis
Copy link

mkuklis commented Sep 19, 2013

@Davidiusdadi do you know when this one will get merged? Thank you.

Davidiusdadi added a commit that referenced this pull request Sep 23, 2013
made websocket client use java.net instead of java.nio
@Davidiusdadi Davidiusdadi merged commit 115477e into TooTallNate:master Sep 23, 2013
@shuckc
Copy link

shuckc commented Oct 6, 2015

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?

@daluu
Copy link

daluu commented Feb 8, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants