Error with Ticker data

sunnylbk
Hello
I have been seeing the following error frequently now when subscribing to tick data

Connected
Subscribed to tick
Subscribe again: [12335618] map[12335618:empty]
Connected
Subscribed to tick
Error: Error reading data: websocket: unexpected reserved bits 0x70
Reconnect attempt 1 in 2.000000s
Reconnect attempt 2 in 4.000000s
Connected
Subscribed to tick
Subscribe again: [12335618] map[12335618:empty]
Error: Error reading data: read tcp 169.254.76.1:51646->52.66.55.203:443: use of closed network connection
Connected
Subscribed to tick


Any ideas on how to resolve this?

Once this happens, API seems to make multiple requests to recover and I eventually see `Too many requests` error.

Thanks
  • rakeshr
    @sunnylbk
    Which connect client are you using?
  • sujith
    Can you paste your complete code here?
  • sunnylbk
    sunnylbk edited November 2019
    It was mostly from example code
    // Triggered when any error is raised
    func onError(err error) {
    fmt.Println("Error: ", err)
    }

    // Triggered when websocket connection is closed
    func onClose(code int, reason string) {
    fmt.Println("Close: ", code, reason)
    }

    // Triggered when connection is established and ready to send and accept data
    func onConnect() {
    fmt.Println("Connected")
    err := ticker.Subscribe(instrumentsToSubscribe)
    if err != nil {
    fmt.Println("err: ", err)
    }
    }

    // Triggered when tick is received
    func onTick(tick kiteticker.Tick) {
    zerodhaTickerChannel <- tick
    }

    // Triggered when reconnection is attempted which is enabled by default
    func onReconnect(attempt int, delay time.Duration) {
    fmt.Printf("Reconnect attempt %d in %fs\n", attempt, delay.Seconds())
    }

    // Triggered when maximum number of reconnect attempt is made and the program is terminated
    func onNoReconnect(attempt int) {
    fmt.Printf("Maximum no of reconnect attempt reached: %d", attempt)
    }

    // Triggered when order update is received
    func onOrderUpdate(order kiteconnect.Order) {
    //
    }



    and the ticker // Assign callbacks
    ticker.OnError(onError)
    ticker.OnClose(onClose)
    ticker.OnConnect(onConnect)
    ticker.OnReconnect(onReconnect)
    ticker.OnNoReconnect(onNoReconnect)
    ticker.OnTick(onTick)
    ticker.OnOrderUpdate(onOrderUpdate)
    // Start the connection
    ticker.Serve()
Sign In or Register to comment.