Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    java sdk websocket - com.neovisionaries.ws.client.WebSocketException: The status line of the opening handshake response is empty

    NodeJS SDK
    0
    1
    12
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nagappan08 last edited by

      Generated the jwttoken by using api client id to get the generate session.

       String clientId = "xxx";
              SmartConnect smartConnect = new SmartConnect();
              String apiKey = "xxx";
              // Provide your API key here
              smartConnect.setApiKey(apiKey);
              User user = smartConnect.generateSession(clientId, "xxx", tOtp);
              System.out.println("jwt token : "+  user.getAccessToken());
              String jwtToken = user.getAccessToken();
      

      Then

      SmartWebsocket smartWebsocket = new SmartWebsocket(clientId, jwtToken, apiKey, actionType, feedType);
      
              smartWebsocket.setOnConnectedListener(new SmartWSOnConnect() {
      
                  @Override
                  public void onConnected() {
                      System.out.println("smart web socket connected..");
                      smartWebsocket.runscript();
                  }
              });
      
              smartWebsocket.setOnDisconnectedListener(new SmartWSOnDisconnect() {
                  @Override
                  public void onDisconnected() {
                      System.out.println("onDisconnected");
                  }
              });
      
              /** Set error listener to listen to errors. */
              smartWebsocket.setOnErrorListener(new SmartWSOnError() {
                  @Override
                  public void onError(Exception exception) {
                      System.out.println("onError: " + exception.getMessage());
                  }
      
                  @Override
                  public void onError(SmartAPIException smartAPIException) {
                      System.out.println("onError: " + smartAPIException.getMessage());
                  }
      
                  @Override
                  public void onError(String error) {
                      System.out.println("onError: " + error);
                  }
              });
      
              smartWebsocket.setOnTickerArrivalListener(new SmartWSOnTicks() {
                  @Override
                  public void onTicks(JSONArray ticks) {
                      System.out.println("ticker data: " + ticks.toString());
                  }
              });
      
              /**
               * connects to SmartAPI ticker server for getting live quotes
               */
              smartWebsocket.connect();
      

      While connecting getting the below exception - opening handshake is empty.

      com.neovisionaries.ws.client.WebSocketException: The status line of the opening handshake response is empty.
      at com.neovisionaries.ws.client.HandshakeReader.readStatusLine(HandshakeReader.java:99)

      1 Reply Last reply Reply Quote 0
      • First post
        Last post