MtGox streaming API - not receiving messages

-3

Although it was working previously (like a day ago), I now am not receiving any messages through the MtGox streaming API (socket.io). Code is below, am I doing anything obviously wrong? The connection message is printing out so I assume it's connected OK.

var conn = io.connect('https://socketio.mtgox.com/mtgox');

conn.on('connect', function(data) {
    console.log("Connected to Mt.Gox");
    conn.send({
      "op": "mtgox.subscribe",
      "type": "depth"
    });
    conn.send({
      "op": "mtgox.subscribe",
      "type": "trade"
    });
});

conn.on('message', function(data) {
    if ('private' === data.op) {
        if ('trade' === data.private && 'USD' === data.trade.price_currency) {
            console.log("Last trade price: " + data.trade.price);
        }
        if ('depth' === data.private) {
            if ('ask' === data.depth.type_str) {
                console.log("Ask depth added: " + data.depth.price);
            } else {
                console.log("Bid depth added: " + data.depth.price);
            }
        }
    }
});

lkavenagh

Posted 2013-10-30T15:20:26.240

Reputation: 1

Link to jsfiddle: http://jsfiddle.net/lkavenagh/jYKjU/17/

console.log wasn't working for some reason so used alert instead. I get the connection alert but no alerts for messages.

lkavenagh 2013-10-31T17:37:54.847

Just discovered that if I leave it running for something like 30-45 minutes, it starts receiving messages. Will try to find out why there is such a delay...lkavenagh 2013-11-02T16:13:31.510

Answers

0

Not 100% sure, my project is still working. Only difference I might see is the way you subscribe to the channel, I use a channel ID instead of a type. Not sure if that might have something to do with it. I'm a sort of novice programmer, just gettin back into it after years of sitting idle. Let me know if that helps

Andy Visser

Posted 2013-10-30T15:20:26.240

Reputation: 1

I've tried that too. Hmm, I had thought it might be on Mt.Gox's side, but it doesn't look that way.lkavenagh 2013-10-31T03:31:21.467