☰
Login
Signup
Home
›
Market data (WebSockets)
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Register
Categories
Recent Discussions
Activity
Categories
14K
All Categories
0
Incidents
156
Node JS client
40
Go client
794
.Net API client
382
Kite Publisher
537
.Net / VBA / Excel (3rd party)
460
Algorithms and Strategies
1K
Java client
1.1K
API clients
404
PHP client
4K
Python client
348
Mobile and Desktop apps
1.4K
Market data (WebSockets)
3.4K
General
In this Discussion
January 2024
sujith
January 2024
marsonya
Only getting Blob with different sizes in Websocket
marsonya
January 2024
in
Market data (WebSockets)
Hi, I am able to successfully connect to the Websocket and receiving text messages.
But, I am not getting ticks properly. I am continuously (more than a few times in a second) getting the following message that the parser is not able to parse:
data: Blob {
size: 560 // this keeps changing
type: ""
}
marsonya
January 2024
I am not using any client directly. I have copied the Parser from NodeJS NPM Client.
onMessage: (message) => {
console.log(message);
this.connected = true;
if(message.data instanceof ArrayBuffer) {
console.log(message.data.byteLength)
if(message.data.byteLength > 2) {
const parsedData = this.parseBinary(message.data);
this.updatePrices(parsedData);
console.log('binary message', parsedData);
}
}else {
const parsedText = this.parseTextMessage(message.data)
if(parsedText) {
console.log('text message', parsedText);
}
}
}
The code is not passing "if(message.data instanceof ArrayBuffer) {"
marsonya
January 2024
@sujith
, please help me
sujith
January 2024
The tick data is in binary. You can read more about it from the API
documentation
.
marsonya
January 2024
edited January 2024
@sujith
I understand that. And I am following the exact thing written in Kite NPM Package
https://github.com/zerodha/kiteconnectjs/blob/master/lib/ticker.ts#L400
The problem is message.data is coming as undefined.
But I am getting empty Blob messages. I would really appreciate if you can nudge me in the right direction.
marsonya
January 2024
Issue resolved. I had to convert the Blob data to Array buffer using const buffer = await blob.arrayBuffer();
Thanks
This discussion has been closed.
onMessage: (message) => {
console.log(message);
this.connected = true;
if(message.data instanceof ArrayBuffer) {
console.log(message.data.byteLength)
if(message.data.byteLength > 2) {
const parsedData = this.parseBinary(message.data);
this.updatePrices(parsedData);
console.log('binary message', parsedData);
}
}else {
const parsedText = this.parseTextMessage(message.data)
if(parsedText) {
console.log('text message', parsedText);
}
}
}
The code is not passing "if(message.data instanceof ArrayBuffer) {"
https://github.com/zerodha/kiteconnectjs/blob/master/lib/ticker.ts#L400
The problem is message.data is coming as undefined.
But I am getting empty Blob messages. I would really appreciate if you can nudge me in the right direction.
Thanks