Pages:
Author

Topic: [BETA] MTGox websocket API, testers wanted - page 16. (Read 77653 times)

legendary
Activity: 1692
Merit: 1018
You need to include certain bytes before and after every json message. I think no newlines. This would be hard to do in telnet. I suggest taking a hard look at this post which has haskell code that I think would still work:

https://bitcointalksearch.org/topic/m.87198

Thanks for that.  I'll try putting \x00 before my message and \xFF after and see how that goes. 
hero member
Activity: 609
Merit: 505
You need to include certain bytes before and after every json message. I think no newlines. This would be hard to do in telnet. I suggest taking a hard look at this post which has haskell code that I think would still work:

https://bitcointalksearch.org/topic/m.87198
legendary
Activity: 1692
Merit: 1018
You should not be getting a disconnect just for sending an invalid message type. You should be getting a json message back that says something about how your command was unrecognized. I would double check the bytes you're sending. As a test, you can try to unsubscribe to one of the feeds. That works, so you should be able to get it to work.

It seems I can't send anything to MtGox after the initial handshake without getting disconnected.

I've tried in telnet too (MS Windows telnet client).  Surely it should work?

telnet websocket.mtgox.com 80
Sent the following text:
GET /mtgox HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: websocket.mtgox.com
Origin: null

After pressing enter the second time I start to get the stream of data.

But when I try to send something like "{'op': 'mtgox.unsubscribe', 'key': 24e67e0d-1cad-4cc0-9e7a-f8523ef460fe}" the connection is lost.  If I send anything at all the connection dies.

I don't get it.  

EDIT: Just tried it again with Putty on Win7.  Type of connection: raw.  Same result.  I can get the streaming data, but as soon as I try to send anything back to the server on the same connection it disconnects.
hero member
Activity: 609
Merit: 505
You should not be getting a disconnect just for sending an invalid message type. You should be getting a json message back that says something about how your command was unrecognized. I would double check the bytes you're sending. As a test, you can try to unsubscribe to one of the feeds. That works, so you should be able to get it to work.
legendary
Activity: 1692
Merit: 1018
Subscribing to my own channel doesn't work either.  I'm using VB and tried sending ANSI strings to MtGox in various formats, but as soon as I do I lose the TCP connection.  Sending the handshake right after connecting exactly the same way works fine however.

I have tried:

{'key': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', 'op': 'mtgox.subscribe'}
{'key': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', 'op': 'subscribe'}
{'op': 'mtgox.subscribe', 'key': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'}
{'op': 'subscribe', 'key': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'}

Sending nonsensical data "eg. 'testing 123' to the connection causes a disconnection as well.  Is this standard behaviour if MtGox doesn't recognise the message?

I assume the key is my key listed in my MtGox API section.  I have successfully used the key and secret to retrieve account data using a sample PHP script.

EDIT: Just tried using plain old telnet to connect to MtGox.  Works fine, just like this example:
http://dl.dropbox.com/u/24900303/screenshot/2011/04/20110415_websocket_telnet_example.png

But as soon as I try to send any subsequent data to the connection I lose it.  The wiki entry at https://en.bitcoin.it/wiki/MtGox/API is non descriptive. 

"Additionally each user has a "own" channel which streams informations about orders (new order, deleted order, etc) and trades only the user's trades). "

There is no description on how someone can subscribe to their own channel.
hero member
Activity: 609
Merit: 505
I have not been able to get the "own" channel to work either. If anyone has, please share how!
hero member
Activity: 784
Merit: 1009
firstbits:1MinerQ
Does the "own" channel work at all?

I can't figure out how to get data about my own trades/orders. I've dumped all the data streamed and there is no data not matching the default channels. I tried subscribing using a key of my own account. That doesn't work either. It seems like this just doesn't work yet.

It would be really useful to see when your own orders/trades occur. If this does work then is there a web page somewhere that says more than the one line on the wiki?

*** Edit:

Another thing I noticed now is multi-currency trades coming thru. I don't quite understand these:

19:07:57 BUY  22.81 @ $2.63192 GBP
19:07:57 BUY  22.81 @ $25.6 CNY

I see British Pounds and Chinese Yuan. But why twice and how does this work - is someone buying with Pounds and settling in Yuan or something? I realize that this must be the same trade since the  GBPCNY exchange rate is now about 10.33. Just not sure how I can handle this as info if the USD isn't indicated.

Thx.
hero member
Activity: 548
Merit: 502
So much code.
I found the part of the draft where Chrome 14 is failing:

http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10#section-4.2

Apparently, MtGox is setting the RSV2 bit in the responses to the client. Thus, according to the spec, Chrome is required to FAIL the connection.

Using a packet sniffer, I can see the subscribed responses from the WebSocket after connecting, but the message never gets through and Chrome fails and closes the connection.

This is such a simple fix...
legendary
Activity: 2126
Merit: 1001
September 25, 2011, 12:28:12 PM
I was going to make a nice interface for the feed as well, but I'm not going to bother until the problems are resolved:
Rounding issues
No perfect way to start out in-sync
Alleged missing data and dark pool inconsistencies

How about these and the wss://?
Its been months that Mark didnt post here now..

And, general question:
I chose this API as a starting project to learn ruby.  Maybe a bit (too) ambitious, but would at least be a useable project, if it ever gets finished..
Are there real advantages of this "new" websocket API over the old HTTP API except that I dont have to poll any more and have instant updates (instead of every 10 secs)? I would at least not have the syncing issues?

With the probably still unsolved issues I hesitate to invest much more time into this - being a novice I still am trying to actually post to the websocket.. *rolleyes*

Thanks,

Ente
legendary
Activity: 924
Merit: 1004
Firstbits: 1pirata
September 24, 2011, 01:50:28 PM
sup MagicalTux, any plans to update websockets to draft-10 any time soon ? Thanks
sr. member
Activity: 398
Merit: 250
September 22, 2011, 07:42:50 PM
yeah, this should work?
I know that ws://mtgoxlive.com:3456/channel works Tongue

MtGox! Anyone there?
hero member
Activity: 966
Merit: 501
PredX - AI-Powered Prediction Market
September 20, 2011, 08:58:38 AM
Yay! Correct thread to complain about that!

Indeed, me too want clarkmoody on Chrome 14!

(thankfully at work Chrome is still stuck on 13)
AV
hero member
Activity: 910
Merit: 1000
September 20, 2011, 08:56:57 AM
Hi, MagicalTux !

The WebSocket API really does not work with the latest (14.0.835.163) Chrome.


For example http://bitcoin.clarkmoody.com/
WebSocket Closed after 2 second.

Help ! Help ! Help !

Thanks.
legendary
Activity: 2053
Merit: 1356
aka tonikt
September 20, 2011, 05:52:43 AM
The WebSocket API does not work with the latest Chrome. Sad

Chrome dev claims that the problem is at mtgox side.
Quote
It seems that websocket.mtgox.com is sending out a frame in old format (http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00). Chrome 14 uses new version WebSocket protocol (http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-08). We've dropped old protocol and are asking servers to adopt new one. mtgox is replying new version handshake correctly. Only new frame support looks broken.
http://code.google.com/p/chromium/issues/detail?id=97026

Please fix.
legendary
Activity: 2053
Merit: 1356
aka tonikt
imho, all changes must be. human's or robot's..
agree. but these dont look like robot changes, do they? why would a robot do something like that? the only thing i can think of: to DoS the server Smiley
newbie
Activity: 23
Merit: 0
It happens very often that there are consecutive "depth" messages, where one comes immediately after another and they both have the same amount/price and the opposite sign. So effectively they do nothing, except causing confusion and an unnecessary traffic.

For instance:
Quote
{"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","depth":{"currency":"USD","item":"BTC","price":"8.86852","price_int":"886852","type":2,"type_str":"bid","volume":"-0.79287883","volume_int":"-79287883"},"op":"private","origin":"broadcast","private":"depth"}
{"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","depth":{"currency":"USD","item":"BTC","price":"8.86852","price_int":"886852","type":2,"type_str":"bid","volume":"0.79287883","volume_int":"79287883"},"op":"private","origin":"broadcast","private":"depth"}

It seems like some glitch and it would be nice if could be fixed one day.

imho, all changes must be. human's or robot's..
legendary
Activity: 2053
Merit: 1356
aka tonikt
It happens very often that there are consecutive "depth" messages, where one comes immediately after another and they both have the same amount/price and the opposite sign. So effectively they do nothing, except causing confusion and an unnecessary traffic.

For instance:
Quote
{"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","depth":{"currency":"USD","item":"BTC","price":"9.15417","price_int":"915417","type":1,"type_str":"ask","volume":"-0.09283","volume_int":"-9283000"},"op":"private","origin":"broadcast","private":"depth"}
{"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","depth":{"currency":"USD","item":"BTC","price":"9.15417","price_int":"915417","type":1,"type_str":"ask","volume":"0.09283","volume_int":"9283000"},"op":"private","origin":"broadcast","private":"depth"}
...
{"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","depth":{"currency":"USD","item":"BTC","price":"8.86","price_int":"886000","type":2,"type_str":"bid","volume":"-0.2","volume_int":"-20000000"},"op":"private","origin":"broadcast","private":"depth"}
{"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","depth":{"currency":"USD","item":"BTC","price":"8.86","price_int":"886000","type":2,"type_str":"bid","volume":"0.2","volume_int":"20000000"},"op":"private","origin":"broadcast","private":"depth"}
{"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","depth":{"currency":"USD","item":"BTC","price":"8.86","price_int":"886000","type":2,"type_str":"bid","volume":"-0.2","volume_int":"-20000000"},"op":"private","origin":"broadcast","private":"depth"}
...
{"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","depth":{"currency":"USD","item":"BTC","price":"8.86852","price_int":"886852","type":2,"type_str":"bid","volume":"-0.79287883","volume_int":"-79287883"},"op":"private","origin":"broadcast","private":"depth"}
{"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","depth":{"currency":"USD","item":"BTC","price":"8.86852","price_int":"886852","type":2,"type_str":"bid","volume":"0.79287883","volume_int":"79287883"},"op":"private","origin":"broadcast","private":"depth"}

It seems like some glitch and it would be nice if could be fixed one day.
hero member
Activity: 674
Merit: 500
You have a small bug in the reply header:
Code:
HTTP/1.1 101 WebSocket Protocol Handshake
should be the first line, and in your case it's
Code:
HTTP/1.1 101 Web Socket Protocol Handshake
(yes, the additional space between Web and Socket). Nothing major, however if some software validates the header, it won't be recognized as a valid one. Example of such real-world failing app: websocket-sharp. Other are probably just failing silently too.
full member
Activity: 158
Merit: 100
Websocket API is cool for receiving trade updates! Thanks!

But is it possible to receive updates on my orders anyhow?
If that is implemented, then I don't get the meaning of the "(partial key)" in
Code:
{
  "channel":"(partial key)",
  "op":"private",
  "order_upd":{
    "amount":1000,
    "darkStatus":0,
    "date":1302836027,
    "oid":"(oid)",
    "price":0.9899,"status":1
  },
  "origin":"broadcast",
  "private":"order_upd"
}
(example from https://en.bitcoin.it/wiki/MtGox/API#Websocket_API )

I don't understand how should I implement the authentication to subscribe to my private channel.

Please, can anybody provide more details on:

 1. Does it work at the moment?
 2. How the authentication is implemented?

Also, it would be nice to be able to request the full depth to receive them as depth messages.
newbie
Activity: 7
Merit: 0

Reading the different channels, updating data all works perfect... but -

how can i connect my account to get my trading information?

sending
{"op":"mtgox.subscribe","key":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}

will always result in

{"message":"Invalid MTGOX key","op":"remark","success":false}


XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX is the API Key from the https://mtgox.com/users/settings page.
Or are i'm compleatly wrong?


Thanks.
Pages:
Jump to: