Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

96
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda