Failed to fetch quote data: Error parsing response. - Go SDK

proximus
Incredibly weird bug that I am facing in gokiteconnect + AWS fargate setup.

I have deployed my backend on AWS Fargate and all other routes work fine but when I try hitting my api route which runs GetQuote, I get the data correctly in local development but it gives `Failed to fetch quote data: Error parsing response.` on prod for some weird reason.
All other routes work fine, such as GetLTP, GetOHLC and even portfolio related routes.
func (c *DataController) GetQuote(w http.ResponseWriter, r *http.Request) {
instrumentsQuery := r.URL.Query().Get("instruments")
if instrumentsQuery == "" {
c.logger.Error().Msg("GetQuote request missing 'instruments' query parameter")
http.Error(w, "'instruments' query parameter is required", http.StatusBadRequest)
return
}

instruments := strings.Split(instrumentsQuery, ",")

quoteData, err := c.dataService.GetQuote(r.Context(), instruments)
if err != nil {
c.logger.Error().Err(err).Msg("Failed to fetch quote data")
http.Error(w, "Failed to fetch quote data: "+err.Error(), http.StatusInternalServerError) // Error getting triggered
return
}

w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(quoteData)
}
dataService is just a gokiteconnect SDK wrapper. This standard is followed on all routes so I dont think its the code having a problem, especially since it works fine on local.

envs/secrets are set up correctly since other routes are dependent on them and they work just fine.

This leads me to believe this is a problem on the devops level and not the SDK. Is kite api perhaps blocking requests for this route from this region? Weird question but cant place my finger on anything surely

Images:
Development:


Production:


Postman environment setup is correct.

GetLTP working fine in prod:




More Info:
Region: ap-south-1
SDK: gokiteconnect v4.3.5
Tagged:
  • proximus
    I have also tried redeploying my service instance on AWS so that is also one possibility gone.
  • sujith
    You seem to be send the wrong query param label. It should be i. You can know more here.
  • proximus
    I think the gokiteconnect SDK takes care of that part, and it works fine in development

    Moreover my backend expects params in the way I send, as seen in the code snippet and it parses and uses the SDK's GetQuote as shared below

    https://pkg.go.dev/github.com/zerodhatech/gokiteconnect#:~:text=Client)%20GetQuote%20%C2%B6-,func%20(c%20*Client)%20GetQuote(instruments%20...string)%20(Quote%2C%20error),-GetQuote%20gets%20map

    The SDK afaik takes care of parsing the string input and converts it to proper params
  • rakeshr
    There is ot of abstraction in the image you posted, which makes it difficult for us to debug this issue further.
    You might not be parsing the instruments parameter correctly. It has to be sent as e.g.:
    kc.GetQuote("NSE:INFY", "NSE:RELIANCE") to GetQuote.
    You can enable HTTP logging by using SetDebug to inspect the issue further and see exactly what's being sent to the API.
  • proximus
    Yup, I'm following that exactly as specified in documentation and it works perfectly fine as expected on local end to end, but when I build the image and push it to AWS only this specific route fails, which makes is weird to debug too, will try debugging on prod and let you know soon
Sign In or Register to comment.