Navigation

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

    WebSocket connection error WebSocketException: The status line of the opening handshake response is empty

    NodeJS SDK
    0
    1
    19
    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

      We are using the below way of conneecting and generating the 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 we need to connect the websocket with the user details as below:

      public void smartWebSocketUsage(String clientId, String jwtToken, String apiKey, String actionType, String feedType)
                  throws SmartAPIException {
      
              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 the websocket, we are facing this issue.. "opening handshake response is empty.."

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