Navigation

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

    Websocket connection failed

    Java SDK
    1
    2
    2
    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.
    • A
      arun8483 last edited by

      
              SmartStreamListener listener = new SmartStreamListener() {
      
                  @Override
                  public void onConnected() {
                      System.out.println("[WS] Connected to Angel One feed");
                      
                      
                  }
      
                  @Override
                  public void onDisconnected() {
                      System.out.println("[WS] Connection closed");
                      alerts.send("⚠️ WebSocket disconnected");
                  }
      
                  @Override
                  public void onError(SmartStreamError error) {
                  	System.err.println("========== WS ERROR ==========");
                      System.err.println("Message : " + error.getException().getMessage());
                      System.err.println("Code    : " + error.getException().getLocalizedMessage());
                      System.err.println("Details : " + error);
                   
                      System.err.println("================================");
                      
                  }
      
                  @Override
                  public void onPong() {
                      // optional
                  }
      
                  @Override
                  public SmartStreamError onErrorCustom() {
                      return null;
                  }
      
                  // ── THIS replaces your onTick ─────────────────────────
      
                  @Override
                  public void onLTPArrival(LTP ltp) {
                      try {
                          /*LiveTick lt = new LiveTick(
                                  "BANKNIFTY",
                                  ltp.getLastTradedPrice() / 100.0,  // paise → ₹
                                  0,
                                  LocalDateTime.now()
                          );
      
                          runner.onTick(lt);
      					*/
                      } catch (Exception e) {
                          System.err.println("[TICK ERROR] " + e.getMessage());
                      }
                  }
      
                  // unused but required
      
                  @Override
                  public void onQuoteArrival(Quote quote) {}
      
                  @Override
                  public void onSnapQuoteArrival(SnapQuote snapQuote) {}
      
                  @Override
                  public void onDepthArrival(Depth depth) {}
              };
      
      
              // ── Create ticker ─────────────────────────────────────────
              System.out.println("clientId: " + auth.getClientId());
              System.out.println("feedToken: " + auth.getFeedToken());
              SmartStreamTicker ticker = new SmartStreamTicker(
                      auth.getClientId(),
                      auth.getFeedToken(),
                      listener
              );
      
      
              // ── Subscribe to BankNifty Futures ───────────────────────
      
              Set<TokenID> tokenSet = new HashSet<>();
      
              tokenSet.add(new TokenID(
                      ExchangeType.NSE_FO,   // Futures exchange
                      futures.getSymbolToken()
              ));
      
              ticker.subscribe(SmartStreamSubsMode.LTP, tokenSet);
      
      
              // ── Connect ──────────────────────────────────────────────
      
              ticker.connect();
      

      ========== WS ERROR ==========
      Message : null
      Code : null
      Details : com.angelbroking.smartapi.smartstream.models.SmartStreamError@443dbe42

      1 Reply Last reply Reply Quote 0
      • A
        arun8483 last edited by arun8483

        ========== WS ERROR ==========
        Message : null
        Code    : null
        Details : com.angelbroking.smartapi.smartstream.models.SmartStreamError@443dbe42
        ================================
        

        Its not even showing what the error is.
        There is no proper way to print and see what the error is

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