Navigation

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

    Not getting connected to Websocket2.0

    General Discussion
    0
    3
    33
    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.
    • M
      Manish Choudhary last edited by

      from SmartApi.smartConnect import SmartConnect
      from SmartApi.smartWebSocketV2 import SmartWebSocketV2
      from pyotp import TOTP
      import login as l

      obj=SmartConnect(api_key=l.api_key)
      data=obj.generateSession(clientCode=l.user_name,password=l.password,totp=TOTP(l.token).now())
      Feed_token=obj.getfeedToken()
      Auth_token=data['data']['jwtToken']
      prof=obj.getProfile(data['data']['refreshToken'])

      sws=SmartWebSocketV2(auth_token=Auth_token,api_key=l.api_key,client_code=l.user_name,feed_token=Feed_token)

      def on_open(wsapp):
      print("open")
      sws.subscribe(correlation_id="stream_1",mode=3,token_list=[{"exchangeType": 1, "tokens": "1594"}])

      def on_data(wsapp,message):
      print("Tick : {}".format(message))

      def on_error(wsapp,error):
      print(error)

      sws.on_open=on_open
      sws.on_data=on_data
      sws.on_error=on_error

      sws.connect()

      -----------------------CODE------------------------------
      On open
      [E 240129 15:00:23 smartWebSocketV2:218] Error occurred during subscribe: 'str' object has no attribute 'extend'
      [W 240129 15:00:23 smartWebSocketV2:326] Attempting to resubscribe/reconnect (Attempt 1)...
      On open
      [E 240129 15:00:44 smartWebSocketV2:218] Error occurred during subscribe: 'str' object has no attribute 'extend'

      Connection closed
      [W 240129 15:00:45 smartWebSocketV2:350] Connection closed due to max retry attempts reached.

      Connection closed
      [W 240129 15:00:45 smartWebSocketV2:350] Connection closed due to max retry attempts reached.

      Connection closed
      [W 240129 15:00:45 smartWebSocketV2:350] Connection closed due to max retry attempts reached.

      Connection closed
      [W 240129 15:00:45 smartWebSocketV2:350] Connection closed due to max retry attempts reached.

      Connection closed
      [W 240129 15:00:45 smartWebSocketV2:350] Connection closed due to max retry attempts reached.

      M 1 Reply Last reply Reply Quote 1
      • M
        Moderator_2 @Manish Choudhary last edited by

        Hi @Manish-Choudhary

        Apologies for delayed response.
        Please reverify on the no of connection, we have limit of three connection Websocket smartAPI, if total connection per client count reached 3 all new connection will be blocked.

        Thanks & Regards,
        SmartAPI team

        P 1 Reply Last reply Reply Quote 0
        • P
          perceptron @Moderator_2 last edited by

          @Moderator_2 I am still getting the same error anyway. I have just initiated one socket.

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