Web Socket opening handshake timeout


  • 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)
    

  • @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)


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


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

    authorizationError: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
    code: 1006
    

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


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


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


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


  • 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