I subscribed to two symbols and then unsubscribed one symbol.after unsubscribe, I keep getting below error message
ERROR:root:payload_creation :: ERR : -> Line:286 Exception:unpack requires a buffer of 12 bytes
I subscribed to two symbols and then unsubscribed one symbol.after unsubscribe, I keep getting below error message
ERROR:root:payload_creation :: ERR : -> Line:286 Exception:unpack requires a buffer of 12 bytes
In FYERS Community - Pick others' brains on Trading/Investing you can ask and answer questions and share your experience with others!
Hi, FYERS Team,
Below error msg keeps coming after unsubscribe
prc, qty, num_ord = constants.FY_P_MARKET_PIC.unpack( struct.error: unpack requires a buffer of 12 bytes ERROR:root:payload_creation :: ERR : -> Line:540 Exception:unpack requires a buffer of 12 bytes
Hi Sanind, can you show me the code where you unsubscribe?
Below is subscribe..
orderedSymbols is List here
self.fyerswbSocket.subscribe(
symbol=orderedSymbols, data_type="symbolData")
Below is the unsubscribe... Note here i am unsubscribing one or more symbols but not all symbols
self.fyerswbSocket.unsubscribe([symbol.optionSymbol])
Hey, can you try to create a new thread in python to call the unsubscribe function?
Can you share a sample code for that Please?
I'll try coding it when I have time and send it to you.
By the way how is the unsubscribe and threadiing related to Unpack error?
waiting......
Still waiting @Fyers team can anyone help please?
I am also getting the same error. Can this be check on priority.
@Fyers team @Vikram Sri
Any update on this? I am also facing the same error
@Vikram Sri
I tried as you below. Still, I see the same issue.
I believe the issue should be from the server, after unsubscribing still server sends Invalid market data. It suggests investigating from the server side why that msg.
t = Thread(target=fyersSocket.unsubscribe, args=(["NSE:L&TFH-EQ"],))
t.start()
Hi Fyers Team,
Any update?
@Vikram Sri Any update?
Any update?
I have done some RND and discoverd that this error is coming due to a bug in Unsubscribe enpoint.
Whenever we call the unsubscible and pass the list of symbols, it doesn't actually unsubscribe but instead it only removes the 'market_pic': [] from the payload and continues to send the data.
This causes the unpack method to fail as it is not able to get the required length of data.
I added below two IF statements in the ws.py file at the respective places where the unpack is being called. The error were removed. But the websocket keeps on running.
if (len(self.message[:constants.FY_P_LEN_HEADER])) >= 24:
if (len(self.message[:constants.FY_P_LEN_BID_ASK])) >= 12:
Here is the output that now I get post the unsubscribe:
On Subscribe:
Custom:[{'symbol': 'NSE:GRASIM-EQ', 'timestamp': 1674032987, 'fyCode': 7208, 'fyFlag': 2, 'pktLen': 200, 'ltp': 1669.0, 'open_price': 1668.0, 'high_price': 1686.8, 'low_price': 1663.95, 'close_price': 1660.7, 'min_open_price': 1668.55, 'min_high_price': 1669.95, 'min_low_price': 1668.55, 'min_close_price': 1669.0, 'min_volume': 7414, 'last_traded_qty': 5, 'last_traded_time': 1674032986, 'avg_trade_price': 167532, 'vol_traded_today': 588688, 'tot_buy_qty': 101221, 'tot_sell_qty': 111542, 'market_pic': [{'price': 1668.95, 'qty': 47, 'num_orders': 3}, {'price': 1668.9, 'qty': 39, 'num_orders': 1}, {'price': 1668.85, 'qty': 26, 'num_orders': 3}, {'price': 1668.75, 'qty': 950, 'num_orders': 2}, {'price': 1668.7, 'qty': 20, 'num_orders': 1}, {'price': 1669.5, 'qty': 1, 'num_orders': 1}, {'price': 1669.7, 'qty': 18, 'num_orders': 2}, {'price': 1669.75, 'qty': 1, 'num_orders': 1}, {'price': 1669.85, 'qty': 7, 'num_orders': 1}, {'price': 1669.9, 'qty': 3, 'num_orders': 1}]}]
Post Unsubscribe:
Custom:[{'symbol': 'NSE:GRASIM-EQ', 'timestamp': 1674033011, 'fyCode': 7208, 'fyFlag': 2, 'pktLen': 104, 'ltp': 1669.0, 'open_price': 1668.0, 'high_price': 1686.8, 'low_price': 1663.95, 'close_price': 1660.7, 'min_open_price': 1669.0, 'min_high_price': 1669.4, 'min_low_price': 1668.85, 'min_close_price': 1669.0, 'min_volume': 504, 'last_traded_qty': 13, 'last_traded_time': 1674033010, 'avg_trade_price': 167531, 'vol_traded_today': 589677, 'tot_buy_qty': 100449, 'tot_sell_qty': 111998, 'market_pic': []}]
The only reason it felt like the unsubscirbe call removes the symbols is because of failure, it was not giving the symbol data.
@Vikram Sri @Fyers team @Vanshika Singh @Yashas Khoday - A issue reported 5 months back, how long will take this. Why fyers Websocket is not stable still ? Webhook callbacks is also not working. !
Yes, Its very bad on Fyers Part. @Fyers Fyers @Fyers team . Such a small fix.. They are not doing it