Bitcoin Forum

Economy => Trading Discussion => Topic started by: eldentyrell on February 05, 2012, 10:20:34 PM



Title: MtGox Streaming API is Broken
Post by: eldentyrell on February 05, 2012, 10:20:34 PM
Here is a self-contained piece of code that demonstrates the problem:

Code:
import io.socket.*;
import org.json.*;
import net.tootallnate.websocket.*;

public class MtGoxStreaming {
    
    private static final String tickerChannel = "d5f06780-30a8-4a48-a2f8-7ed181b4a13f";
    private static final String tradesChannel = "dbf1dee9-4f2e-4a08-8cb7-748919a71b21";
    private static final String depthChannel  = "24e67e0d-1cad-4cc0-9e7a-f8523ef460fe";

    public static void main(String[] args) throws Exception {
        SocketIO socket = new SocketIO("https://socketio.mtgox.com/mtgox");
        socket.connect(new IOCallback() {
                @Override
                    public void onMessage(JSONObject json, IOAcknowledge ack) {
                    try {
                        System.out.println("We received a message: " + json.toString(2));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }

                @Override
                    public void onMessage(String data, IOAcknowledge ack) {
                    System.out.println("We received a message:" + data);
                }
                
                @Override
                    public void onError(SocketIOException socketIOException) {
                    System.out.println("Something went wrong: " + socketIOException);
                    socketIOException.printStackTrace();
                    //System.exit(0);
                }

                @Override
                    public void onDisconnect() {
                    System.out.println("Disconnected");
                    System.exit(0);
                }

                @Override
                    public void onConnect() {
                    System.out.println("Connected");
                }

                @Override
                    public void on(String event, IOAcknowledge ack, Object... args) {
                    System.out.println("got: " + event);
                    ack.ack("Roger that!");
                    //socket.emit("answer", new JSONObject().put("msg", "Hello again Socket.io!"));
                }
            });

        // This will be cached until the server is connected.
        //socket.emit("hello", new JSONObject().put("msg", "Hello Socket.io! :D"));
 
        JSONObject obj = new JSONObject();
        obj.put("op",      "subscribe");
        //obj.put("channel", depthChannel);
        obj.put("channel", "d5f06780-30a8-4a48-a2f8-7ed181b4a13f");
        socket.send(obj);
 
    }
}

Run it and you get:

Code:
Connected
> 1::/mtgox
> 4::/mtgox:{"op":"subscribe","channel":"d5f06780-30a8-4a48-a2f8-7ed181b4a13f"}
> 2::
> 2::
> 2::
> 2::
> 2::
> 2::
> 2::
< 7:::1+0
Something went wrong: io.socket.SocketIOException: 1+0
io.socket.SocketIOException: 1+0


Title: Re: MtGox Streaming API is Broken
Post by: runeks on February 22, 2012, 10:28:59 PM
I wish they could just re-enable the old socket API. It was working fine for me. I can't get the new one to work either (with Python).


Title: Re: MtGox Streaming API is Broken
Post by: MagicalTux on February 23, 2012, 12:43:04 AM
I wish they could just re-enable the old socket API. It was working fine for me. I can't get the new one to work either (with Python).

Actually the old one was disabled because it was causing too much strain on the system. We are working on a viable solution (socket.io seemed to be used by some big players, but after testing this ourselves we found out it's far from being stable at all).

Anyway we got another option currently on planning stage that may go live by end of may if socket.io do not fix their thing by then.


Title: Re: MtGox Streaming API is Broken
Post by: Serge on February 23, 2012, 07:24:14 AM
with broken live data feed/s you're missing an action  /me thinks


Title: Re: MtGox Streaming API is Broken
Post by: toffoo on February 23, 2012, 11:22:03 PM
Anyway we got another option currently on planning stage that may go live by end of may ...

What is your current recommendation for people who need a stable live price feed?

The current socket.io and/or websockets feeds have been really awful the past few days/(weeks?).  While occasionally seeming to work at times, they often go down for hours at a time, pretty much every day.

What do sites like Bitcoinica, trading bots, or merchant sites do when the Mt.Gox feed goes down for hours at a time?

Is "maybe wait until the end of May" the only option here?


Title: Re: MtGox Streaming API is Broken
Post by: Seal on February 25, 2012, 04:56:26 AM
Anyway we got another option currently on planning stage that may go live by end of may ...

What is your current recommendation for people who need a stable live price feed?

The current socket.io and/or websockets feeds have been really awful the past few days/(weeks?).  While occasionally seeming to work at times, they often go down for hours at a time, pretty much every day.

What do sites like Bitcoinica, trading bots, or merchant sites do when the Mt.Gox feed goes down for hours at a time?

Is "maybe wait until the end of May" the only option here?


The JSON web API with post/get calls.

*edit* actually i just realised you asked for live feed... the json calls aren't live.


Title: Re: MtGox Streaming API is Broken
Post by: daybyter on February 26, 2012, 08:09:02 PM
Wouldn't it be easier to get the json server update more often?  How quick is enough 'real time'?