code: private WebSocketMessage<?> receive(WebSocketEndpointConfiguration config, long timeout) {
          long timeLeft = timeout;
  
          WebSocketMessage<?> message = config.getHandler().getMessage();
          String path = endpointConfiguration.getEndpointUri();
          while (message == null && timeLeft > 0) {
              timeLeft -= endpointConfiguration.getPollingInterval();
              long sleep = timeLeft > 0 ? endpointConfiguration.getPollingInterval() : endpointConfiguration.getPollingInterval() + timeLeft;
              if (LOG.isDebugEnabled()) {
                  String msg = "Waiting for message on '%s' - retrying in %s ms";
                  LOG.debug(String.format(msg, path, (sleep)));
              }
  
              try {
                  Thread.sleep(sleep);
              } catch (InterruptedException e) {
                  LOG.warn(String.format("Thread interrupted while waiting for message on '%s'", path), e);
              }
  
              message = config.getHandler().getMessage();
          }
  
          if (message == null) {
              throw new ActionTimeoutException(String.format("Action timed out while receiving message on '%s'", path));
          }
          return message;
      }
docs: Receive web socket message by polling on web socket handler for incoming message.
  @param config
  @param timeout
  @return