tyrus
  1. tyrus
  2. TYRUS-181

WebSocket client ignores the ProxySelector

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-rc3
    • Fix Version/s: 1.1
    • Component/s: None
    • Labels:
      None
    • Environment:

      Linux

      Description

      When you are running the client, it seems like the java.net.ProxySelector is not invoked or used so the normal proxy selection mechanism is not used.

      For example in this very simple self-serving case, the select method is never called.

      public static void main(String[] args) throws DeploymentException, IOException {
      
      
              final ProxySelector defaultPS = ProxySelector.getDefault();
              ProxySelector.setDefault(new ProxySelector() {
      
                  @Override
                  public List<Proxy> select(URI uri) {
                      return defaultPS.select(uri);
                  }
      
                  @Override
                  public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
                      defaultPS.connectFailed(uri, sa, ioe);
      
                  }
              });
      
      
      
              try {
                  Server server = new Server("localhost", 7101, "/Project1", EchoService.class);
                  server.start();
      
                  // Right now we have to create a client
      
      
                  ClientManager client = ClientManager.createClient();
      
                  EchoBeanClient beanClient = new EchoBeanClient();
      
                  Session session =
                      client.connectToServer(beanClient, ClientEndpointConfig.Builder.create().build(),
                                             URI.create("ws://localhost:7101/Project1/echo"));
      
                  // Wait until things are closed down
      
                  while (session.isOpen()) {
                      System.out.println("Waiting");
                      TimeUnit.MILLISECONDS.sleep(10);
                  }
      
                  //
      
                  //
      
                  System.out.println("Client session closed, presume we have a result " + session);
      
      
              } catch (Exception ex) {
      
                  ex.printStackTrace(System.out);
              }
      
      
          }

      This is the standard method of configuring a proxy in the JDK and should be observed.

        Activity

        gdavison created issue -
        Pavel Bucek made changes -
        Field Original Value New Value
        Assignee Pavel Bucek [ pavel_bucek ]
        Fix Version/s 1.1 [ 16467 ]
        Pavel Bucek made changes -
        Description When you are running the client, it seems like the java.net.ProxySelector is not invoked or used so the normal proxy selection mechanism is not used.

        For example in this very simple self-serving case, the select method is never called.

            public static void main(String[] args) throws DeploymentException, IOException {


                final ProxySelector defaultPS = ProxySelector.getDefault();
                ProxySelector.setDefault(new ProxySelector() {

                    @Override
                    public List<Proxy> select(URI uri) {
                        return defaultPS.select(uri);
                    }

                    @Override
                    public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
                        defaultPS.connectFailed(uri, sa, ioe);

                    }
                });



                try {
                    Server server = new Server("localhost", 7101, "/Project1", EchoService.class);
                    server.start();

                    // Right now we have to create a client


                    ClientManager client = ClientManager.createClient();

                    EchoBeanClient beanClient = new EchoBeanClient();

                    Session session =
                        client.connectToServer(beanClient, ClientEndpointConfig.Builder.create().build(),
                                               URI.create("ws://localhost:7101/Project1/echo"));

                    // Wait until things are closed down

                    while (session.isOpen()) {
                        System.out.println("Waiting");
                        TimeUnit.MILLISECONDS.sleep(10);
                    }

                    //

                    //

                    System.out.println("Client session closed, presume we have a result " + session);


                } catch (Exception ex) {

                    ex.printStackTrace(System.out);
                }


            }

        This is the standard method of configuring a proxy in the JDK and should be observed.
        When you are running the client, it seems like the java.net.ProxySelector is not invoked or used so the normal proxy selection mechanism is not used.

        For example in this very simple self-serving case, the select method is never called.

            {code}public static void main(String[] args) throws DeploymentException, IOException {


                final ProxySelector defaultPS = ProxySelector.getDefault();
                ProxySelector.setDefault(new ProxySelector() {

                    @Override
                    public List<Proxy> select(URI uri) {
                        return defaultPS.select(uri);
                    }

                    @Override
                    public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
                        defaultPS.connectFailed(uri, sa, ioe);

                    }
                });



                try {
                    Server server = new Server("localhost", 7101, "/Project1", EchoService.class);
                    server.start();

                    // Right now we have to create a client


                    ClientManager client = ClientManager.createClient();

                    EchoBeanClient beanClient = new EchoBeanClient();

                    Session session =
                        client.connectToServer(beanClient, ClientEndpointConfig.Builder.create().build(),
                                               URI.create("ws://localhost:7101/Project1/echo"));

                    // Wait until things are closed down

                    while (session.isOpen()) {
                        System.out.println("Waiting");
                        TimeUnit.MILLISECONDS.sleep(10);
                    }

                    //

                    //

                    System.out.println("Client session closed, presume we have a result " + session);


                } catch (Exception ex) {

                    ex.printStackTrace(System.out);
                }


            }{code}

        This is the standard method of configuring a proxy in the JDK and should be observed.
        Pavel Bucek made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Pavel Bucek
            Reporter:
            gdavison
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: