# Only receiving KA messages, no data

**URL:** <https://community.bitquery.io/t/only-receiving-ka-messages-no-data/2309>\
**Category:** GraphQL API\
**Tags:** support\
**Created:** [March 12, 2025, 3:51pm UTC](https://community.bitquery.io/t/only-receiving-ka-messages-no-data/2309 "2025-03-12T15:51:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnthopkins](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@johnthopkins](https://community.bitquery.io/u/johnthopkins)\
**Post date:** [March 12, 2025, 3:51pm UTC](https://community.bitquery.io/t/only-receiving-ka-messages-no-data/2309/1 "2025-03-12T15:51:24Z")

</div>

I’m trying to wet my beak in the Bitquery stream and I’m able to make a connection just fine, and I receive Keep Alive messages, but I have yet to receive any data. Is there something wrong with my config? What could be causing this?

```auto
const WebSocket = require("ws");

// === CONFIGURATION ===
const ASSET = "BTC"; // Change this to ETH, etc.
const FIAT = "USD"; // Change to USDT, EUR, etc.
const MIN_SPREAD = 0.50; // Minimum price difference before alerting arbitrage

// WebSocket URLs
const EXCHANGES = {
    binance: "wss://stream.binance.com:9443/ws/btcusdt@trade",
    kraken: "wss://ws.kraken.com",
    bitstamp: "wss://ws.bitstamp.net"
};

// Store live prices
const prices = {
    binance: null,
    kraken: null,
    bitstamp: null
};

// === FUNCTION TO HANDLE MESSAGES ===
function handleMessage(exchange, data) {
    let price = null;

    try {
        const parsedData = JSON.parse(data);

        if (exchange === "binance") {
            price = parseFloat(parsedData.p);
        } else if (exchange === "kraken" && parsedData[1]?.c) {
            price = parseFloat(parsedData[1].c[0]);
        } else if (exchange === "bitstamp" && parsedData.data?.price) {
            price = parseFloat(parsedData.data.price);
        }

        if (price) {
            prices[exchange] = price;
            console.log(`💰 ${exchange.toUpperCase()} ${ASSET} Price: $${price.toFixed(2)}`);
            checkArbitrage();
        }
    } catch (error) {
        console.error(`❌ Error processing ${exchange} data:`, error.message);
    }
}

// === FUNCTION TO CHECK ARBITRAGE ===
function checkArbitrage() {
    const exchanges = Object.keys(prices);
    for (let i = 0; i < exchanges.length; i++) {
        for (let j = i + 1; j < exchanges.length; j++) {
            const exchangeA = exchanges[i];
            const exchangeB = exchanges[j];
            const priceA = prices[exchangeA];
            const priceB = prices[exchangeB];

            if (priceA && priceB) {
                const spread = Math.abs(priceA - priceB);
                console.log(`🔄 ${exchangeA.toUpperCase()} vs ${exchangeB.toUpperCase()} Spread: $${spread.toFixed(2)}`);

                if (spread >= MIN_SPREAD) {
                    console.log(`🚀 **Arbitrage Opportunity!** Buy on ${priceA < priceB ? exchangeA.toUpperCase() : exchangeB.toUpperCase()} ($${Math.min(priceA, priceB).toFixed(2)}) and Sell on ${priceA > priceB ? exchangeA.toUpperCase() : exchangeB.toUpperCase()} ($${Math.max(priceA, priceB).toFixed(2)})`);
                }
            }
        }
    }
}

// === CONNECT TO WEBSOCKETS ===
function connectToExchange(exchange) {
    console.log(`📡 Connecting to ${exchange.toUpperCase()} WebSocket...`);
    const ws = new WebSocket(EXCHANGES[exchange]);

    ws.on("open", () => {
        console.log(`✅ Connected to ${exchange.toUpperCase()}`);
        if (exchange === "kraken") {
            ws.send(JSON.stringify({ event: "subscribe", pair: [`${ASSET}/${FIAT}`], subscription: { name: "ticker" } }));
        } else if (exchange === "bitstamp") {
            ws.send(JSON.stringify({ event: "bts:subscribe", data: { channel: `live_trades_${ASSET.toLowerCase()}${FIAT.toLowerCase()}` } }));
        }
    });

    ws.on("message", (data) => handleMessage(exchange, data));

    ws.on("error", (err) => console.error(`❌ ${exchange.toUpperCase()} WebSocket error:`, err));
    ws.on("close", () => {
        console.log(`🔴 ${exchange.toUpperCase()} WebSocket closed. Reconnecting in 5s...`);
        setTimeout(() => connectToExchange(exchange), 5000);
    });
}

// === START BOT ===
Object.keys(EXCHANGES).forEach(connectToExchange);

```

---

<div class="post-metadata">

**Author:** ![Divya](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@Divya](https://community.bitquery.io/u/Divya)\
**Post date:** [March 25, 2025, 1:56pm UTC](https://community.bitquery.io/t/only-receiving-ka-messages-no-data/2309/2 "2025-03-25T13:56:58Z")

</div>

Hello, I don’t see any suage of Bitquery here. Only kraken and binance.
