Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

97
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda