Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
ActionCable stops working with no output - Javascript

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.

enter image description here

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

First of all ,i recommend using Socket.io for working with sockets rather than sorare.

Your code is correct and if there are no logs related to 'disconnect' or 'rejected' events ,there is no problem with your connection either. maybe there is problem with your target server's event emitting and your server is not receiving any events after a while.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!