tyrus
  1. tyrus
  2. TYRUS-176

connectToServer returning before connection is complete

    Details

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

      JDK 1.7u10

      Description

      If you run the following code:

                   for (int i = 0; i < 100; i++) {
                     ClientManager client = ClientManager.createClient();
                     EchoBeanClient beanClient = new EchoBeanClient();
      
                     Session session = client.connectToServer(
                             beanClient, 
                             ClientEndpointConfig.Builder.create().build(),
                             URI.create("ws://localhost:8025/echo"));
      
                     session.getBasicRemote().sendText("OtherHello");
      
                     // Wait until things are closed down
      
                     if (false)
                     {
                         while (session.isOpen()) {
                             System.out.println("Waiting");
                             TimeUnit.MILLISECONDS.sleep(10);
                         }
                     }
                     else {
                         beanClient.latch.await();
                         session.close();
                     }
      
                     //
      
                     System.out.println("Client session closed, presume we have a result "  + session);
                 }

      You will find that it will fail around 6/1000 times with the following exception:

      INFO: WebSocket server started.
      Server connected SessionImpl{uri=/echo, id='b101e686-b40b-4c93-8f60-b06c8040a18d', endpoint=EndpointWrapper{endpointClass=null, endpoint=org.glassfish.tyrus.core.AnnotatedEndpoint@7da150, uri='/echo', contextPath='/'}} javax.websocket.server.DefaultServerEndpointConfig@1e98b70
      java.lang.RuntimeException: Socket is not connected.
      	at org.glassfish.tyrus.container.grizzly.GrizzlyClientSocket.send(GrizzlyClientSocket.java:229)
      	at org.glassfish.tyrus.server.TyrusRemoteEndpoint.sendText(TyrusRemoteEndpoint.java:101)
      	at org.glassfish.tyrus.core.RemoteEndpointWrapper.sendSyncText(RemoteEndpointWrapper.java:187)
      	at org.glassfish.tyrus.core.RemoteEndpointWrapper$Basic.sendText(RemoteEndpointWrapper.java:86)
      	at websocket.EchoBeanMain.main(EchoBeanMain.java:42)

      This would suggest there is some kind of race condition going on.

        Activity

        Hide
        Pavel Bucek added a comment -

        fixed in the trunk

        Show
        Pavel Bucek added a comment - fixed in the trunk
        Hide
        gdavison added a comment -

        I can provide test data; but the link to attach files appears to be missing.

        Show
        gdavison added a comment - I can provide test data; but the link to attach files appears to be missing.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: