Stream API - SUM_IMAGE not received for all subscription

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsteinert
    Junior Member
    • Jul 2020
    • 5

    #1

    Stream API - SUM_IMAGE not received for all subscription

    Evening all,

    I'm having some trouble with the Stream API not returning an initial image for some of my subscriptions.

    I'm connecting to the API with the below function:


    async connect() {
    const APIKey = betfairAPIClient.getAPIKey();
    const sessionToken = await betfairAPIClient.getSessionToken();

    /* Socket connection options */
    const options = { host: 'stream-api.betfair.com', port: 443 }
    /* Establish connection to the socket */
    this.client = tls.connect(options);
    /* Send authentication message */
    this.client.write('{"op": "authentication", "appKey": "' + APIKey + '", "session": "' + sessionToken + '"}\r\n');

    this.client.on('data', this.onData.bind(this));
    this.client.on('close', this.onClose.bind(this));
    this.client.on('error', this.onError.bind(this));
    }

    And subscribing with this:

    const marketSub = {
    op: "marketSubscription",
    id: id,
    marketFilter: { marketIds: [market] },
    marketDataFilter: { fields: ["EX_ALL_OFFERS"], ladderLevels: 3 },
    };

    this.client.write(JSON.stringify(marketSub) + '\r\n');


    This works fine when subscribing to just one market, but when subscribing to multiple markets (currently 6) by sending 6 different subscription messages I receive success messages for all 6, but SUB_IMAGE messages for only a few.

    The SUM_IMAGEs received vary, but are commonly just numbers 5 and 6, and I rarely if ever receive number 1.

    I receive no errors and have confirmed that every message is being acted on with Wireshark.

    Is there some kind of rate limit for subscriptions that I'm violating?
  • LiamP
    Junior Member
    • Oct 2015
    • 284

    #2
    As per the docs:

    It is possible to subscribe multiple times - each replaces the previous (each will send a new initial image and deltas) - they are not additive.

    https://docs.developer.betfair.com/d...riptionMessage

    Comment

    • gsteinert
      Junior Member
      • Jul 2020
      • 5

      #3
      Hi Liam,

      Thank you for the response.

      That's all understood (and quite useful in my context), but I don't think it's related to the issue I'm having.

      I subscribe to 6 different markets and receive 6 confirmations, but then only receive initial images for a few of them.

      The below is example output - onData, onClose and onBind just output to console for now.

      [0] {"op":"status","statusCode":"SUCCESS","connecti onC losed":false,"connectionsAvailable":1}
      [0]
      [0] {"op":"status","id":1,"statusCode":"SUCCESS","c onn ectionClosed":false}
      [0]
      [0] {"op":"status","id":2,"statusCode":"SUCCESS","c onn ectionClosed":false}
      [0]
      [0] {"op":"status","id":3,"statusCode":"SUCCESS","c onn ectionClosed":false}
      [0]
      [0] {"op":"status","id":4,"statusCode":"SUCCESS","c onn ectionClosed":false}
      [0]
      [0] {"op":"status","id":5,"statusCode":"SUCCESS","c onn ectionClosed":false}
      [0]
      [0] {"op":"status","id":6,"statusCode":"SUCCESS","c onn ectionClosed":false}
      [0]
      [0] {"op":"mcm","id":6,"initialClk":"whqYyLqQB8wa2o GOl gfFGsn7vJcH","clk":"AAAAAAAA","conflateMs":180000, "heartbeatMs":5000,"pt":1599761145870,"ct":"SU B_IM AGE","mc":[{"id":"1.172884531","rc":[{"atb":[[50,4.88],[48
      ,9.37],[1.03,1220].....

      See the initial SUCCESS messages for ids 1-6, but an initial image is only received for id 6. The six markets subscribed to all have different IDs.

      Comment

      • LiamP
        Junior Member
        • Oct 2015
        • 284

        #4
        You are seeing exactly as described in the docs, not sure there is a better way to explain it:

        ..each replaces the previous (each will send a new initial image and deltas) - they are not additive.

        You need to take advantage of the market filter (list) if you want to subscribe to multiple markets.

        Comment

        • gsteinert
          Junior Member
          • Jul 2020
          • 5

          #5
          Ah okay I think I get it.

          If I subscribe to market 123, then subscribe separately to market 456 before I receive the initial image, the second subscription replaces the first.

          If the subscription to 123 completes and I get the inital image, then i subscribe to 456 I'll get both images.

          Does that sound about right?


          I think I just need to queue and batch subscriptions so I don't send a scond before the first completes.

          Thanks for your help, that gives me something to work on.

          Comment

          • LiamP
            Junior Member
            • Oct 2015
            • 284

            #6
            No it’s one subscription per stream/socket, if you want multiple markets:

            ... marketFilter: { marketIds: [market, market, market, market] },

            Comment

            • gsteinert
              Junior Member
              • Jul 2020
              • 5

              #7
              Third time lucky then!

              To subscribe to one market, then later add another I'd need to do:

              subscribe( { marketFilter: { marketIds: [ 123 ] } } )

              ...then later...

              subscribe( { marketFilter: { marketIds: [ 123, 456 ] } } )

              At which point I'd receive a new inital image for market 123, then deltas for them both?

              Comment

              • LiamP
                Junior Member
                • Oct 2015
                • 284

                #8
                Sort of, they are not additive so the second subscribe would be a new subscription for both. You have to be coarse, for example subscribing to all UK racing markets, streaming is lightweight so just ignore the markets you don’t need.

                Comment

                • gsteinert
                  Junior Member
                  • Jul 2020
                  • 5

                  #9
                  Sounds good to me.

                  Thank you for your help!

                  Comment

                  Working...
                  X