☰
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
13.8K
All Categories
0
Incidents
151
Node JS client
39
Go client
790
.Net API client
377
Kite Publisher
537
.Net / VBA / Excel (3rd party)
456
Algorithms and Strategies
991
Java client
1.1K
API clients
402
PHP client
4K
Python client
345
Mobile and Desktop apps
1.4K
Market data (WebSockets)
3.3K
General
In this Discussion
January 8
sujith
January 8
marsonya
Only getting Blob with different sizes in Websocket
marsonya
January 8
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 8
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 8
@sujith
, please help me
sujith
January 8
The tick data is in binary. You can read more about it from the API
documentation
.
marsonya
January 8
edited January 8
@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 8
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