Bitcoin Forum

Economy => Service Discussion => Topic started by: loourr on August 31, 2013, 11:29:48 PM



Title: Mtgox Websockets API only working sometimes
Post by: loourr on August 31, 2013, 11:29:48 PM
I have a class which collects data from mtgox (written in coffeescript) using websockets. The trouble is that it only works sometimes. I never change the code but sometimes when I start it, it will continually log in on message and other times it wont. If it dosent start right off the bat, regardless of how long I leave it on it will not begin to work. However if I restart the process it may start immediately or it may once again not work. It seems totally random.

Has anyone else had this problem? Is there some way to fix it? am I doing something wrong?

here's my code

events = require 'events'
io = require 'socket.io-client'
colors = require 'colors'
config = require "../config/config"
module.exports = class Mtgox extends events.EventEmitter

    constructor: () ->

        @socket = io.connect(config.MTGOX_WEBSOCKET_URL)
        @channels = config.MTGOX_CHANNELS

        @socket.on('connect', () =>
            console.log "in main on connect"
            @socket.on('message', (message) =>
                console.log "in on message"
                @emit(message.private, message[message.private])
            )
        )


Title: Re: Mtgox Websockets API only working sometimes
Post by: ofer on September 04, 2013, 07:59:57 PM
Hi,
I can confirm this issue.
I have a sokcet.io connected to mtgox in nodejs environment.
I also get the same behavior.

I now consider to use their REST API, since this behavior is unacceptable for production.

Hope this helps,
Ofer


Title: Re: Mtgox Websockets API only working sometimes
Post by: tgerring on September 04, 2013, 09:56:26 PM
Has anyone else had this problem? Is there some way to fix it? am I doing something wrong?

Yes. No. Yes, relying on MtGox websockets after a long track record of crap websockets.


Title: Re: Mtgox Websockets API only working sometimes
Post by: Jan on September 05, 2013, 03:39:26 PM
Maybe related to this: https://bitcointalk.org/index.php?topic=286422.0


Title: Re: Mtgox Websockets API only working sometimes
Post by: loourr on September 16, 2013, 08:19:45 PM
Quote
I now consider to use their REST API, since this behavior is unacceptable for production.

I was using their REST API until I realized that sometimes it would just give flat out incorrect data.


Title: Re: Mtgox Websockets API only working sometimes
Post by: jav on September 16, 2013, 10:06:40 PM
My understanding is, that Mt.Gox offers two streaming interfaces: Socket.IO and Websockets. Socket.IO has the option of using Websockets as one of the underlying transport mechanisms, but it still seems to be dealt with differently by Mt.Gox's server. I have long used Socket.IO for Bridgewalker (when I launched it was the only option available, as far as I know) and had lots of issues with it. It was very unreliable and actually got even more unreliable in the last couple of weeks. I have now recently switched to a pure Websocket implemention (using wss://websocket.mtgox.com/mtgox as the endpoint) and so far that seems to be more stable. So I would suggest replacing Socket.IO with a pure Websocket implementation.