☰
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
383
Kite Publisher
537
.Net / VBA / Excel (3rd party)
462
Algorithms and Strategies
1K
Java client
1.1K
API clients
405
PHP client
4K
Python client
349
Mobile and Desktop apps
1.4K
Market data (WebSockets)
3.4K
General
In this Discussion
January 15
sujith
January 14
avnikk
AggregateError in Websocket
avnikk
January 14
in
Market data (WebSockets)
type: 'error',
message: '',
error: AggregateError [EHOSTUNREACH]:
at internalConnectMultiple (node:net:1139:18)
at afterConnectMultiple (node:net:1712:7) {
code: 'EHOSTUNREACH',
[errors]: [ [Error], [Error] ]
}
}
avnikk
January 14
i am trying to connect it, but it keeps getting disconnected after few mins
avnikk
January 14
@sujith
avnikk
January 14
@rakeshr
avnikk
January 14
if i send any invalid or null token, or null value to socket will it close the socket??
avnikk
January 14
edited January 14
please let me know if code needed of execution
avnikk
January 14
update : it is still getting disconnected
avnikk
January 14
WebSocket error: ErrorEvent {
10|Zerodha | target: WebSocket {
10|Zerodha | _events: [Object: null prototype] {
10|Zerodha | open: [Function],
10|Zerodha | message: [Function],
10|Zerodha | error: [Function],
10|Zerodha | close: [Function]
10|Zerodha | },
10|Zerodha | _eventsCount: 4,
10|Zerodha | _maxListeners: undefined,
10|Zerodha | readyState: 2,
10|Zerodha | protocol: '',
10|Zerodha | _binaryType: 'arraybuffer',
10|Zerodha | _closeFrameReceived: false,
10|Zerodha | _closeFrameSent: false,
10|Zerodha | _closeMessage: '',
10|Zerodha | _closeTimer: null,
10|Zerodha | _closeCode: 1006,
10|Zerodha | _extensions: {},
10|Zerodha | _receiver: null,
10|Zerodha | _sender: null,
10|Zerodha | _socket: null,
10|Zerodha | _isServer: false,
10|Zerodha | _redirects: 0,
10|Zerodha | url: 'wss://ws.kite.trade/?api_key=&access_token=&uid=',
10|Zerodha | _req: null,
10|Zerodha | [Symbol(shapeMode)]: false,
10|Zerodha | [Symbol(kCapture)]: false
10|Zerodha | },
10|Zerodha | type: 'error',
10|Zerodha | message: '',
10|Zerodha | error: AggregateError [EHOSTUNREACH]:
10|Zerodha | at internalConnectMultiple (node:net:1139:18)
10|Zerodha | at afterConnectMultiple (node:net:1712:7) {
10|Zerodha | code: 'EHOSTUNREACH',
10|Zerodha | [errors]: [ [Error], [Error] ]
10|Zerodha | }
10|Zerodha | }
sujith
January 14
Make sure you are not blocking the thread on which you are receiving ticks.
avnikk
January 14
would this work?
function onTicks(data1) {
try {
if (!Array.isArray(data1)) return;
data1.forEach(data => {
if (!data || data.mode !== 'full') {
return;
}
// Offload the publish operation to a later iteration of the event loop
setImmediate(() => {
redisPublisher.publish('DataSender', JSON.stringify(data));
});
});
} catch (error) {
console.error(`Error processing message: ${error}`);
}
}
avnikk
January 14
@sujith
avnikk
January 14
did not work sujith, it is still keeps getting disconnect works for few mins then stops working, keeps diconnecting
avnikk
January 14
can u please be quick or connect or call or email, it is causing lot of issue to me any help would be really greatfull
avnikk
January 14
@sujith
sujith
January 14
You shouldn't do anything inside onTicks, offload everything to a secondary thread.
PS: For testing remove everything there.
avnikk
January 14
okay
@sujith
can u help by second thread do i have to make and pass it to another function or do i need to use worker thread to do so?
avnikk
January 14
and
@sujith
what causes this AggregateError?
sujith
January 15
In JavaScript, you need to use async method.
You can read about AggregateError
here
.
Sign In
or
Register
to comment.
10|Zerodha | target: WebSocket {
10|Zerodha | _events: [Object: null prototype] {
10|Zerodha | open: [Function],
10|Zerodha | message: [Function],
10|Zerodha | error: [Function],
10|Zerodha | close: [Function]
10|Zerodha | },
10|Zerodha | _eventsCount: 4,
10|Zerodha | _maxListeners: undefined,
10|Zerodha | readyState: 2,
10|Zerodha | protocol: '',
10|Zerodha | _binaryType: 'arraybuffer',
10|Zerodha | _closeFrameReceived: false,
10|Zerodha | _closeFrameSent: false,
10|Zerodha | _closeMessage: '',
10|Zerodha | _closeTimer: null,
10|Zerodha | _closeCode: 1006,
10|Zerodha | _extensions: {},
10|Zerodha | _receiver: null,
10|Zerodha | _sender: null,
10|Zerodha | _socket: null,
10|Zerodha | _isServer: false,
10|Zerodha | _redirects: 0,
10|Zerodha | url: 'wss://ws.kite.trade/?api_key=&access_token=&uid=',
10|Zerodha | _req: null,
10|Zerodha | [Symbol(shapeMode)]: false,
10|Zerodha | [Symbol(kCapture)]: false
10|Zerodha | },
10|Zerodha | type: 'error',
10|Zerodha | message: '',
10|Zerodha | error: AggregateError [EHOSTUNREACH]:
10|Zerodha | at internalConnectMultiple (node:net:1139:18)
10|Zerodha | at afterConnectMultiple (node:net:1712:7) {
10|Zerodha | code: 'EHOSTUNREACH',
10|Zerodha | [errors]: [ [Error], [Error] ]
10|Zerodha | }
10|Zerodha | }
function onTicks(data1) {
try {
if (!Array.isArray(data1)) return;
data1.forEach(data => {
if (!data || data.mode !== 'full') {
return;
}
// Offload the publish operation to a later iteration of the event loop
setImmediate(() => {
redisPublisher.publish('DataSender', JSON.stringify(data));
});
});
} catch (error) {
console.error(`Error processing message: ${error}`);
}
}
PS: For testing remove everything there.
You can read about AggregateError here.