You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
how to reconnect to websocket i'm not passing the websocket connection as described in the docs
passing only app_id so that api can auto reconnect but still api is disconnecting after an hour and the program exits
here is my code
const api = new DerivAPI({
app_id
});
fx_symbols = ['frxAUDCAD', 'frxAUDJPY', 'frxAUDUSD', 'frxEURAUD', 'frxEURCAD', 'frxEURCHF', 'frxEURGBP', 'frxEURJPY', 'frxEURNZD', 'frxEURUSD','frxNZDUSD', 'frxUSDCAD', 'frxUSDCHF', 'frxUSDJPY',]
fx_candles_1m = {
"frxAUDCAD": [],
"frxAUDJPY": [],
"frxAUDUSD": [],
"frxEURAUD": [],
"frxEURCAD": [],
"frxEURCHF": [],
"frxEURGBP": [],
"frxEURJPY": [],
"frxEURNZD": [],
"frxEURUSD": [],
"frxNZDUSD": [],
"frxUSDCAD": [],
"frxUSDCHF": [],
"frxUSDJPY": [],
}
(async () => {
fx_symbols.map(x => { getAllCandles(x, 60).catch(err => console.log(err)) })
})()
async function getAllCandles(symbol, tf) {
candle_data = await api.candles({ symbol: symbol, granularity: tf, end: "latest", style: "candles", subscribe: 1 })
candle_data.onUpdate(data => {
if (data.raw.epoch === data.raw.open_time + tf - 1) {
// console.log("The candle data for " + symbol + " is : ", data.raw);
o = data.raw.open
h = data.raw.high
l = data.raw.low
c = data.raw.close
epoch = data.raw.epoch + 1
const x = [o, h, l, c, epoch]
const { granularity, id, open_time, pip_size, symbol, ...noA } = data.raw
noA['epoch'] = noA['epoch'] + 1
fx_candles_1m[symbol].push(x)
console.log(symbol, vol_candles_1m[symbol]);
const open = fx_candles_1m[symbol].map(d => d[0])
const high = fx_candles_1m[symbol].map(d => d[1])
const low = fx_candles_1m[symbol].map(d => d[2])
const close = fx_candles_1m[symbol].map(d => d[3])
if (fx_candles_1m[symbol].length > 14) {
let rsi = RSI.calculate({ period: 14, values: close })
console.log("The RSI value of " + symbol + " is ", rsi.slice(-2))
}
if (fx_candles_1m[symbol].length > 15) {
fx_candles_1m[symbol].shift()
}
return Promise.resolve([symbol, data.raw])
}
})
}
what should i do to reconnect if api is disconnected
The text was updated successfully, but these errors were encountered:
As mentioned in the doc, it will automatically reconnect. But it is not happening. To prevent automatically close, you have to send a ping after each 30 sec.
Hello. I am sending {"time":1,"req_id":3,"passthrough":{}} every 30 seconds like the Binary website does, but yet my websocket client is disconnected by the server.
how to reconnect to websocket i'm not passing the websocket connection as described in the docs
passing only app_id so that api can auto reconnect but still api is disconnecting after an hour and the program exits
here is my code
what should i do to reconnect if api is disconnected
The text was updated successfully, but these errors were encountered: