<p>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</p>

CC BY-SA 3.0
2013-10-31T03:31:21.467Z
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
CC BY-SA 3.0
2013-10-30T22:37:03.750Z
2013-10-30T22:37:03.750Z
Andy Visser
<p>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.</p>

<pre><code>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 &amp;&amp; '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);
            }
        }
    }
});
</code></pre>

CC BY-SA 3.0
2013-10-31T17:37:54.847Z
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
CC BY-SA 3.0
2013-11-02T16:13:31.510Z
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
<mtgox><api>
MtGox streaming API - not receiving messages
lkavenagh
# MtGox streaming API - not receiving messages

(Asked by: username_0 on 2013-10-30)

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);
            }
        }
    }
});

```

**Tags:** mtgox, api

> **Comments:**
> **username_0**: Link to jsfiddle: http://jsfiddle.net/username_0/jYKjU/17/  console.log wasn't working for some reason so used alert instead. I get the connection alert but no alerts for messages.  
> **username_0**: 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...  

---

## 1 answers

### Answer by username_1 on 2013-10-30. Score: 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

> **Comments:**
> **username_0**: I've tried that too. Hmm, I had thought it might be on Mt.Gox's side, but it doesn't look that way.  

---

