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

        Hide
        Pavel Bucek added a comment -

        Tyrus client currently does not support proxies at all. Targeted for 1.1 release.

        Show
        Pavel Bucek added a comment - Tyrus client currently does not support proxies at all. Targeted for 1.1 release.
        Hide
        Pavel Bucek added a comment -

        Some simple proxy support is currently in the trunk:

        ClientManager client = ClientManager.createClient();
        client.getProperties().put(GrizzlyClientSocket.PROXY_URI, "http://my.proxy.org:80");
        client.connectToServer( ... );

        There is no ProxySelector support yet (I would need to introduce some kind of properties to have the possibility to disable it and so on, so it was simpler to make a single property to be able to enable proxy per client instance).

        Can you please try current trunk (rev 657+) and let me know whether it works for you?

        Thanks!

        Show
        Pavel Bucek added a comment - Some simple proxy support is currently in the trunk: ClientManager client = ClientManager.createClient(); client.getProperties().put(GrizzlyClientSocket.PROXY_URI, "http: //my.proxy.org:80" ); client.connectToServer( ... ); There is no ProxySelector support yet (I would need to introduce some kind of properties to have the possibility to disable it and so on, so it was simpler to make a single property to be able to enable proxy per client instance). Can you please try current trunk (rev 657+) and let me know whether it works for you? Thanks!
        Hide
        Pavel Bucek added a comment -

        resolving as fixed for Tyrus 1.1; further improvements may be discussed in TYRUS-204.

        Thanks Gerard for verifying and testing

        Show
        Pavel Bucek added a comment - resolving as fixed for Tyrus 1.1; further improvements may be discussed in TYRUS-204 . Thanks Gerard for verifying and testing

          People

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

            Dates

            • Created:
              Updated:
              Resolved: