-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Description
- Trying to get data from websocket with a 100 ticker pairs
- If some pair does not exist i'll get an error message like this and can't continue receive data for other existed pairs:
{"ts":1695230452246,"event":"error","id":1,"code":201030,"message":"pair is not exists, pair: \"XXX_YYY\""}
How to continue get data despite some pairs does not exist?
const CryptoJS = require('crypto-js');
const { createWSConnection } = require('./WebSocketsPolyfill');
const EXMO_WS_BASE_URL = `wss://ws-api.exmo.com:443/v1`;
const EXMO_WS_PUBLIC_URL = `${EXMO_WS_BASE_URL}/public`;
const EXMO_WS_PRIVATE_URL = `${EXMO_WS_BASE_URL}/private`;
function createExmoWSConnection(url, messages) {
const socket = createWSConnection(url);
const onMessage = (event) => console.log('message:', event);
const onClose = (event) => console.log('connection closed:', event);
const onError = (error) => console.log('connection error:', error);
const onInitialize = () => {
console.log('connection opened');
for (let message of messages) {
console.log('sending:', message);
socket.send(message);
}
};
socket.on('open', onInitialize);
socket.on("message", onMessage);
socket.on('close', onClose);
socket.on('error', onError);
}
function connectExmoWSPublicApi() {
const data = [
'{"id":1,"method":"subscribe","topics":["spot/trades:BTC_USD","spot/ticker:LTC_USD", "spot/ticker:XXX_YYY"]}',
];
createExmoWSConnection(EXMO_WS_PUBLIC_URL, data);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels