very slow replies

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gaetanofavoino
    Junior Member
    • Dec 2014
    • 8

    #1

    very slow replies

    Hi guys, I'm experiencing some very slow replies from api service.

    Consider that a few weeks ago everything was ok.

    I just tried the listMarketCatalogue call, but it seems very unstable, sometime timeout, sometime fast reply.

    this is my code snippet
    Code:
    $obj_filter = (object)array(
        'filter' => (object)array(
            'eventTypeIds' => array_keys(1)  
            , 'marketTypeCodes' => array(
                "CORRECT_SCORE_IT"
                , "MATCH_ODDS"
            )
            , 'marketStartTime' => (object)array(
                'from' => date('c', time()-10800)
                , 'to' => date('c', time()+10800)
            )
        )
        , 'sort' => "FIRST_TO_START"
        , 'maxResults' => 40
        , 'marketProjection' => array(
            "RUNNER_DESCRIPTION", "EVENT", "EVENT_TYPE"
        )
    );
    $listMarketCatalogue = sportsApingRequest($sessionToken, 'listMarketCatalogue', json_encode($obj_filter));
    Do you have hany suggestions?

    Last Info: I did the same call from the visualizer, nothing strange happens.

    Maybe can affect: I'm calling the API-NG from Italy

    Thank you for your help
  • betdynamics
    Junior Member
    • Sep 2010
    • 534

    #2
    Given that you are in Italy, is this relevant?

    https://api.developer.betfair.com/se...alian+Exchange

    Comment

    • gaetanofavoino
      Junior Member
      • Dec 2014
      • 8

      #3
      Hi betdynamics, thank you for your reply.
      I read the link, but endpoints are the same, the error is not there.

      I made some step forward: using the visualizer I intercepted the call to the api, translated to curl is this below:

      Code:
      curl 'https://api.betfair.com/exchange/betting/json-rpc/v1' -H 'X-Application: xxxxxxxxxx' -H 'appkey=xxxxxx' -H 'Accept-Encoding: gzip, deflate' -H 'Content-Type: application/json' -H 'X-Authentication: xxxxxxxxxxxxxxxxxxxx=' --data-binary '[{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketCatalogue", "params": {"filter":{"eventTypeIds":["1"],"turnInPlayEnabled":true,"marketBettingTypes":["ODDS"],"marketTypeCodes":["CORRECT_SCORE_IT","MATCH_ODDS"],"marketStartTime":{"from":"2015-02-25T09:00:00Z","to":"2015-02-25T12:30:00Z"}},"sort":"FIRST_TO_START","maxResults":"40","marketProjection":["EVENT_TYPE","EVENT","RUNNER_DESCRIPTION"]}, "id": 1}]' --compressed
      in my code instead I use the betfair provided code:
      Code:
      function sportsApingRequest($sessionToken, $operation, $params)
      {
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_URL, "https://api.betfair.com/exchange/betting/json-rpc/v1");
          curl_setopt($ch, CURLOPT_POST, 1);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($ch, CURLOPT_HTTPHEADER, array(
              'X-Application: ' . APP_KEY,
              'X-Authentication: ' . $sessionToken,
              'Accept: application/json',
              'Content-Type: application/json'
          ));
      
          $postData =
              '[{ "jsonrpc": "2.0", "method": "SportsAPING/v1.0/' . $operation . '", "params" :' . $params . ', "id": 1}]';
      
          curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
      
          //debug('Post Data: ' . $postData);
          $response = json_decode(curl_exec($ch));
          //debug('Response: ' . json_encode($response));
      
          curl_close($ch);
      
          if (isset($response[0]->error)) {
              throw new Exception('Response: ' . json_encode($response)); 
          } else {
              return $response[0]->result;
          }
      }
      I ported the php-curl call to a cli curl call and the problem is gone!
      Code:
      function sportsApingRequest($appKey, $sessionToken, $operation, $params)
      {
      	$cmd = "curl 'https://api.betfair.com/exchange/betting/json-rpc/v1'"
      		." -H 'X-Application: ".APP_KEY."'"
      		." -H 'Accept-Encoding: gzip, deflate'"
      		." -H 'Content-Type: application/json'"
      		." -H 'Accept: */*'"
      		." -H 'X-Requested-With: XMLHttpRequest'"
      		." -H 'Connection: keep-alive'"
      		." -H 'X-Authentication: ".$sessionToken."'"
      		." --data-binary '[{\"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/".$operation."\", \"params\": ".$params.", \"id\": 1}]'"
      		." --compressed"
      		." -s"
      	;
      	exec($cmd,$result);
      	$reply = json_decode($result[0]);
      	return $reply[0]->result;
      }

      very strange, but the problem now is solved, thank you

      Comment

      Working...
      X