Navigation

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

    Web Socket opening handshake timeout

    Python SDK
    4
    9
    64
    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.
    • P
      pranav last edited by

      I'm unable to connect to socket and getting this error before closing connection:

      connection dropped
      1006
      connection was closed uncleanly (WebSocket opening handshake timeout (peer did not finish the opening handshake in time))

      
      def onTick(ws, tick):
          global daySummary
          print('Ticks: ', tick)
          for i in tick:
              try:
                  if i['name']== 'sf':
                      if df.socket(i, daySummary[i['tk']])!=0:
                          daySummary[i['tk']]= df.socket(i, daySummary[i['tk']])
              except:
                  print('some error might have occured. But nothing to worry')
      
      def onConnect(ws, response):
          global feedString
          print('connecting')
          ws.send_request(feedString, 'mw')
      
      def onClose(ws, code, reason):
          ws.stop()
          print('connection dropped')
          print(code)
          print(reason)
      
      def createSocketConnection(symbols):
          feedToken= apiLogin()['feedToken']
          
          tokenList= []
          
          for i in symbols:
              if i in stockTokens:
                  tokenList.append('nse_cm|'+stockTokens[i])
              else:
                  print('{} is not a recognized symbol, check stockTokens.py for reference\ntry again'.format(i))
                  sys.exit()
      
          global feedString
          global daySummary
          feedString= '&'.join(tokenList)
          print(feedString)
          
          daySummary= {
              'currentPrice':'NA',
              'commulativeVolume': 'NA',
              'buyOffers': 'NA',
              'sellOffers': 'NA',
              'bestBuyPrice': 'NA',
              'bestSellPrice': 'NA',
              'bestBuyVol': 'NA',
              'bestSellVol': 'NA'
          }
          
          ss= WebSocket(feedToken, authInfo['clientCode'])
          
          ss.on_connect= onConnect
      
          ss.on_ticks= onTick
      
          ss.on_close= onClose
      
          ss.connect()
          print(feedToken)
      
      1 Reply Last reply Reply Quote 0
      • P
        pranav last edited by

        It was working fine yesterday, I made some changes to the code today. But Ig that should not be a problem as there were no significant changes before ss.connect().
        @admin
        Kindly review this snippet if possible

        A 1 Reply Last reply Reply Quote 0
        • A
          admin @pranav last edited by

          Hi @pranav we will look into this and revert you back.

          S 1 Reply Last reply Reply Quote 0
          • S
            softice @admin last edited by

            @admin I am also facing same problem. I am having double thoughts about developing further on SmartAPI. Its totally unpredictable.

            A 2 Replies Last reply Reply Quote 0
            • A
              admin @softice last edited by

              Hi @softice our team is working on this we will revert back to you soon.

              1 Reply Last reply Reply Quote 0
              • A
                admin @softice last edited by admin

                Hi @softice kindly update python SDK as we have made some changes in web socket.

                P 1 Reply Last reply Reply Quote 0
                • D
                  Diljeet last edited by

                  @admin Facing same issue for Node JS as well.
                  Web socket getting close frequently.

                  authorizationError: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
                  code: 1006
                  
                  A 1 Reply Last reply Reply Quote 0
                  • A
                    admin @Diljeet last edited by

                    Dear @mihirk we have made changes in web socket we will update you once the changes are incorporated for Node JS.

                    1 Reply Last reply Reply Quote 0
                    • P
                      pranav @admin last edited by

                      @admin said in Web Socket opening handshake timeout:

                      SDK as we have made some changes in web socket.

                      updated smartapi-python from 1.2.2 to 1.2.3. But still facing the same issue.
                      btw, did you release any version after that cause 1.2.3 was available yesterday also. And it was not actually updated today (as requirements were already satisfied)

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