tyrus
  1. tyrus
  2. TYRUS-221

wss:// doesn't appear to function correctly via a http proxy.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.3
    • Component/s: None
    • Labels:
      None

      Description

      So I have a fair simple example connecting to a wss:// service using a http proxy:

      package project1;

      import java.io.IOException;

      import java.net.URI;

      import java.util.concurrent.CountDownLatch;
      import java.util.concurrent.TimeUnit;

      import javax.websocket.ClientEndpointConfig;
      import javax.websocket.DeploymentException;
      import javax.websocket.Endpoint;
      import javax.websocket.MessageHandler;
      import javax.websocket.Session;

      import org.glassfish.tyrus.client.ClientManager;
      import org.glassfish.tyrus.container.grizzly.GrizzlyClientSocket;
      import org.glassfish.tyrus.server.Server;

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

      try {

      System.setProperty("javax.net.debug", "all");

      // Start the server

      // Must do this on ADRS

      //

      ClientManager client = ClientManager.createClient();
      client.getProperties().put(GrizzlyClientSocket.PROXY_URI, "http://localhost:8099");

      final CountDownLatch latch = new CountDownLatch(2);

      Endpoint beanClient = new Endpoint()
      {
      @Override
      public void onOpen(Session session, javax.websocket.EndpointConfig endpointConfig) {

      session.addMessageHandler(new MessageHandler.Whole<String>() {

      @Override
      public void onMessage(String message)

      { System.out.println(message); latch.countDown(); }

      });

      }
      };

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

      session.getBasicRemote().sendText("Hello");
      session.getBasicRemote().sendText("Hello");

      // Await the message being echoed back

      latch.await(20, TimeUnit.SECONDS);

      // Close the session

      session.close();

      System.out.println("Everything is just dandy");

      System.exit(0);

      } catch (Exception ex)

      { ex.printStackTrace(System.out); System.exit(255); }

      }
      }

      But rather than the expected CONNECT request to the proxy instead the data sent by the client is binary:

      [0000..0015] 16 03 01 00 95 01 00 00 91 03 01 51 F2 8E 72 94
      [0016..0031] 0B D3 08 D7 A0 E0 72 25 AE 9E D0 02 27 ED 37 F8
      [0032..0047] 12 B4 6F 32 0E 2D 1C D4 B4 1C 04 00 00 2A C0 09
      [0048..0063] C0 13 00 2F C0 04 C0 0E 00 33 00 32 C0 07 C0 11
      [0064..0079] 00 05 C0 02 C0 0C C0 08 C0 12 00 0A C0 03 C0 0D
      [0080..0095] 00 16 00 13 00 04 00 FF 01 00 00 3E 00 0A 00 34
      .... etc

      The output from the java client is as follows:

      javax.websocket.DeploymentException: Handshake response not received.
      at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:305)
      at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:168)
      at project1.TestUsingTyrusOnAdrs.main(TestUsingTyrusOnAdrs.java:57)
      Process exited with exit code 255.

        Activity

        gdavison created issue -
        Hide
        Pavel Bucek added a comment -

        seems like Tyrus client tries to connect via SSL to the local proxy, which is clearly not correct.

        Thanks for the report, will try to fix as soon as possible (but this one actually might need some support on Grizzly side, so it could take a while). Will keep this updated.

        Show
        Pavel Bucek added a comment - seems like Tyrus client tries to connect via SSL to the local proxy, which is clearly not correct. Thanks for the report, will try to fix as soon as possible (but this one actually might need some support on Grizzly side, so it could take a while). Will keep this updated.
        Pavel Bucek made changes -
        Field Original Value New Value
        Assignee Pavel Bucek [ pavel_bucek ]
        Hide
        Pavel Bucek added a comment -

        Initial fix is in the trunk (1.3-SNAPSHOT).

        I need to discuss my approach with Grizzly team, but it would be nice if you can verify the fix - I tried to access wss://echo.websocket.org via internal proxy and it works fine..

        thanks!
        Pavel

        Show
        Pavel Bucek added a comment - Initial fix is in the trunk (1.3-SNAPSHOT). I need to discuss my approach with Grizzly team, but it would be nice if you can verify the fix - I tried to access wss://echo.websocket.org via internal proxy and it works fine.. thanks! Pavel
        Hide
        gdavison added a comment -

        It appears to be doing there right thing now, I can't see it working properly though do apparently to a bug in our proxy code. I will update you when I finally have it working.

        Show
        gdavison added a comment - It appears to be doing there right thing now, I can't see it working properly though do apparently to a bug in our proxy code. I will update you when I finally have it working.
        Hide
        gdavison added a comment -

        Just work out the problem on my end, you can consider this bug resolved from my end.

        Show
        gdavison added a comment - Just work out the problem on my end, you can consider this bug resolved from my end.
        Hide
        Pavel Bucek added a comment -

        great, thanks for evaluation!

        Show
        Pavel Bucek added a comment - great, thanks for evaluation!
        Hide
        Pavel Bucek added a comment -

        fix merged to the master branch (commit a3a3f52edda6062d6e9e2a418776fbd081cf6b6d)

        Show
        Pavel Bucek added a comment - fix merged to the master branch (commit a3a3f52edda6062d6e9e2a418776fbd081cf6b6d)
        Pavel Bucek made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.3 [ 16600 ]
        Resolution Fixed [ 1 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: