I am using the following code in order to get the updates from a server:
const { ActionCable } = require('@sorare/actioncable');
const cable = new ActionCable({
headers: {
// 'Authorization': `Bearer <YourJWTorOAuthToken>`,
// 'APIKEY': '<YourOptionalAPIKey>'
}
});
var query = "aCardWasUpdated(rarities: [limited, rare, super_rare, unique]) " +
"{slug, id, onSale, rarity, liveSingleSaleOffer{price, blockchainId, endDate, open}, player{displayName}}";
cable.subscribe(query, {
connected() {
console.log(new Date().toLocaleString());
console.log("connected");
},
disconnected(error) {
console.log(new Date().toLocaleString());
console.log("disconnected", error);
},
rejected(error) {
console.log(new Date().toLocaleString());
console.log("rejected", error);
},
received(data) {
console.log(new Date().toLocaleString());
if (data?.result?.errors?.length > 0) {
console.log('error', data?.result?.errors);
return;
}
const aCardWasUpdated = data?.result?.data?.aCardWasUpdated;
if (!aCardWasUpdated) {
console.log("A card was not updated");
return;
}
console.log("card");
}
});
That code works fine for some minutes, but after a random amount of time, it stops printing anything.
I am running the code in a screen terminal using node code.js (an then detaching the terminal with ctrl+a+d); but I get the same output using a "normal" terminal.
What could be the issue? Is there a case inside the subscribe function that I am not considering?
