<p>OK, so after playing around with this for a while in the browser I have found out a few things that probably were somewhat obvious. :)</p>

<p>So even if there is no mention that <code>websocket.mtgox.com</code> is different from <code>socketio.mtgox.com</code> it really is, and the difference is that the former is a real WebSocket endpoint while the latter is a Socket.IO endpoint. Of course not very surprising looking at the names ;) Now for a beginner like me that wasn't completely obvious as I assumed Socket.IO could speak WebSocket and thus the endpoints were the same. Hence, this question. This was no the case here.</p>

<p>The Socket.IO endpoint accepts all URI schemes {http, https, ws, wss} while the real WebSocket endpoint only accepts the expected {ws, wss}. </p>

<p>At the moment I have all combinations working.</p>

<pre><code>http://socketio.mtgox.com/mtgox
https://socketio.mtgox.com/mtgox
ws://socketio.mtgox.com/mtgox
wss://socketio.mtgox.com/mtgox

ws://websocket.mtgox.com/mtgox
wss://websocket.mtgox.com/mtgox
</code></pre>

<p>It's unclear it the http and https URI schemes are at all meaningful or if they just happen to work. Probably just that.</p>

<p>In short, there are two hosts: one for Socket.IO and one for WebSocket and both work with or without TLS.</p>

CC BY-SA 3.0
2013-05-06T20:36:05.417Z
2013-05-06T21:26:51.530Z
2013-05-06T21:26:51.530Z
murrekatt
<blockquote>
  <p>Origin null is now allowed.</p>
</blockquote>

<p>Your Origin header is not being set.</p>

<p>Try running your code in the browser from an actual domain name other than something like about:blank.</p>

<p>In chrome running:</p>

<pre><code>var ws = new WebSocket('ws://websocket.mtgox.com/mtgox');
ws.onmessage = function(e){ console.log(e); };
</code></pre>

<p>results in failure from about:blank. However from an actual domain name results in success. </p>

CC BY-SA 3.0
2013-06-08T08:46:19.427Z
Thanks! Yes, that is the case. However, this header is not necessary unless you're a browser according to the standard. MtGox however, enforces this for all.
murrekatt
CC BY-SA 3.0
2013-11-12T05:33:09.923Z
This solved my problem! Thank you so much. I have been stuck for hours!
samol
CC BY-SA 3.0
2013-06-06T18:48:01.337Z
2013-06-06T18:48:01.337Z
Charles Smith
<p>I'm trying to find out what the difference is between <code>websocket.mtgox.com</code> and <code>socketio.mtgox.com</code> for the <a href="https://en.bitcoin.it/wiki/MtGox/API/Streaming" rel="nofollow">MtGox streaming API</a>. Looking at the <a href="https://en.bitcoin.it/wiki/MtGox/API/Streaming#Connecting" rel="nofollow">Connecting section</a> it looks like there are several combinations to be used:</p>

<pre><code>websocket.mtgox.com/mtgox
socketio.mtgox.com/mtgox
</code></pre>

<p>both with <em>http</em> or <em>https.</em></p>

<p>As far as I can see, there is no mention that they are different, however, I know from trying out things myself that they do behave differently. I've also seen in forums that other people have similar questions/problems as I have related to this.</p>

<p>Does anyone know what the differences are? Also are these differences expected and documented somewhere?</p>

<p>Further, the code snippet uses https as the protocol. Excuse my ignorance, but shouldn't we use <em>ws</em> or <em>wss</em> instead of <em>http</em> and <em>https</em>? Can someone explain that difference?</p>

<p>Thanks in advance for any information related to my questions!</p>

<p><b>UPDATE:</b>
Actually, it looks like the <a href="http://en.wikipedia.org/wiki/WebSocket#URI_scheme" rel="nofollow">URI scheme for websockets</a> should be ws: or wss: and not like in the example http: or https:. Maybe this is a typo in the example or what's the deal for MtGox?</p>

<p><b>UPDATE:</b>
So <a href="https://gist.github.com/murrekatt/5526153" rel="nofollow">testing things in the browser</a>, <code>{ws,wss,http,https}://socketio.mtgox.com/mtgox</code> all work and I don't see any difference. On the other hand, <code>{ws,wss,http,https}://websocket.mtgox.com/mtgox</code> all result in HTTP 400 Bad Request. Looking in the browser console I got the following error:</p>

<pre><code>XMLHttpRequest cannot load http://websocket.mtgox.com/socket.io/1/?t=1367857246057. Origin null is not allowed by Access-Control-Allow-Origin.
</code></pre>

<p>Any ideas what might be going on?</p>

CC BY-SA 3.0
2013-05-06T12:27:41.203Z
Let me know if this question should have been posted somewhere else like on stackoverflow.com. Thanks!
murrekatt
<mtgox>
What's the difference between MtGox streaming API hosts?
murrekatt
# What's the difference between MtGox streaming API hosts?

(Asked by: username_0 on 2013-05-06)

I'm trying to find out what the difference is between `websocket.mtgox.com` and `socketio.mtgox.com` for the [MtGox streaming API](https://en.bitcoin.it/wiki/MtGox/API/Streaming). Looking at the [Connecting section](https://en.bitcoin.it/wiki/MtGox/API/Streaming#Connecting) it looks like there are several combinations to be used:

```
websocket.mtgox.com/mtgox
socketio.mtgox.com/mtgox

```

both with *http* or *https.*

As far as I can see, there is no mention that they are different, however, I know from trying out things myself that they do behave differently. I've also seen in forums that other people have similar questions/problems as I have related to this.

Does anyone know what the differences are? Also are these differences expected and documented somewhere?

Further, the code snippet uses https as the protocol. Excuse my ignorance, but shouldn't we use *ws* or *wss* instead of *http* and *https*? Can someone explain that difference?

Thanks in advance for any information related to my questions!

**UPDATE:**
Actually, it looks like the [URI scheme for websockets](http://en.wikipedia.org/wiki/WebSocket#URI_scheme) should be ws: or wss: and not like in the example http: or https:. Maybe this is a typo in the example or what's the deal for MtGox?

**UPDATE:**
So [testing things in the browser](https://gist.github.com/username_0/5526153), `{ws,wss,http,https}://socketio.mtgox.com/mtgox` all work and I don't see any difference. On the other hand, `{ws,wss,http,https}://websocket.mtgox.com/mtgox` all result in HTTP 400 Bad Request. Looking in the browser console I got the following error:

```
XMLHttpRequest cannot load http://websocket.mtgox.com/socket.io/1/?t=1367857246057. Origin null is not allowed by Access-Control-Allow-Origin.

```

Any ideas what might be going on?

**Tags:** mtgox

> **Comments:**
> **username_0**: Let me know if this question should have been posted somewhere else like on stackoverflow.com. Thanks!  

---

## 2 answers

### Answer by username_0 on 2013-05-06. Score: 1 | Accepted answer

OK, so after playing around with this for a while in the browser I have found out a few things that probably were somewhat obvious. :)

So even if there is no mention that `websocket.mtgox.com` is different from `socketio.mtgox.com` it really is, and the difference is that the former is a real WebSocket endpoint while the latter is a Socket.IO endpoint. Of course not very surprising looking at the names ;) Now for a beginner like me that wasn't completely obvious as I assumed Socket.IO could speak WebSocket and thus the endpoints were the same. Hence, this question. This was no the case here.

The Socket.IO endpoint accepts all URI schemes {http, https, ws, wss} while the real WebSocket endpoint only accepts the expected {ws, wss}.

At the moment I have all combinations working.

```
http://socketio.mtgox.com/mtgox
https://socketio.mtgox.com/mtgox
ws://socketio.mtgox.com/mtgox
wss://socketio.mtgox.com/mtgox

ws://websocket.mtgox.com/mtgox
wss://websocket.mtgox.com/mtgox

```

It's unclear it the http and https URI schemes are at all meaningful or if they just happen to work. Probably just that.

In short, there are two hosts: one for Socket.IO and one for WebSocket and both work with or without TLS.


---

### Answer by username_1 on 2013-06-06. Score: 3

> Origin null is now allowed.

Your Origin header is not being set.

Try running your code in the browser from an actual domain name other than something like about:blank.

In chrome running:

```
var ws = new WebSocket('ws://websocket.mtgox.com/mtgox');
ws.onmessage = function(e){ console.log(e); };

```

results in failure from about:blank. However from an actual domain name results in success.

> **Comments:**
> **username_0**: Thanks! Yes, that is the case. However, this header is not necessary unless you're a browser according to the standard. MtGox however, enforces this for all.  
> **username_2**: This solved my problem! Thank you so much. I have been stuck for hours!  

---

