Feedback on ExternalResourceClient vs Guzzle

Hi Sugar Devs,

We'd like to collect some feedback on our Sugar ExternalResourceClient over Guzzle.

Are there functions or functionality that you use in Guzzle that aren't available in ExternalResourceClient?

Could you provide us with some examples that we can use to improve ERC?

Thank you very much,

Rafael Fernandes

  • Hello Rafael,

    The main issue we encountered is linked to the validation of licences of SugarOutfitters using ExternalResssourceClient.

    Before making a API call to a URL, ERC translates the domain name into an IP adress. This poses issues when there are multiple IP adresses behind a domain name making the management of proxy/firewall more difficult and sometimes impossible (on some entry-level solutions). 

    Besides this, all other issues we encountered have been adressed by the Sugar team.

    Kind regards,

    Vlad TANASOIU / Synolia

  • Hi  

    Concurrent HTTP requests

    for example, if we need to execute three independent HTTP requests in one single method.

    Please share your thoughts, thanks.

  •  can you share more about your use case? are they async? do you expect responses for each? can you make an example using curl so we can try to understand?

    SugarCRM | Principal Developer Advocate

  • Hi  

    Yes, async.

    The use case is to send the multiple asynchronous requests and to not wait for the one request.

    https://docs.guzzlephp.org/en/stable/quickstart.html

    We have three HTTP requests, and currently using ExternalResourceClient and making requests one by one, so we call second and third request only once first one is finished. This leads to extra processing time.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    use GuzzleHttp\Client;
    use GuzzleHttp\Promise\Utils;
    $client = new Client(['base_uri' => 'https://api.example.com']);
    $requests = [
    'service_one' => ['POST', '/service-one/data', ['param1' => 'value1', 'param2' => 'value2']],
    'service_two' => ['POST', '/service-two/data', ['paramA' => 'valueA', 'paramB' => 'valueB']],
    'service_three' => ['POST', '/service-three/data', ['paramX' => 'valueX', 'paramY' => 'valueY']],
    ];
    $headers = ['Authorization' => 'Bearer YOUR_ACCESS_TOKEN']; // Example authorization header
    $promises = [];
    foreach ($requests as $key => [$method, $endpoint, $data]) {
    $cleanEndpoint = ltrim($endpoint, '/');
    $promises[$key] = $client->requestAsync(strtoupper($method), $cleanEndpoint, [
    'headers' => $headers,
    'json' => $data
    ]);
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    We would like to do with ExternalResourceClient if that is possible. Please confirm.

    Also confirm, what's the plan for guzzle. Is it going to be depreciated or it will remain in vendor?

    What's the suggestion to achieve this?

    Thanks.

  • Hi  ,

    You're right that ExternalResourceClient doesn't support async calls at the moment. However, I’ve gone ahead and created a feature request to explore adding that functionality in the future.

    To provide some context: when ExternalResourceClient was introduced, we moved away from using Guzzle and cURL since they’re no longer considered best practices and insecure. In fact, cURL is in the denylisted. ExternalResourceClient is Sugar's replacement for these technologies as it aligns with our security best practices.

    At this time, we don't have any plans to remove or deprecate Guzzle. However, we encourage you to avoid using it moving forward, as our plans may change in the future.

    Let me know if you have any more questions or thoughts on this!

    SugarCRM | Principal Developer Advocate

  • Hi  

    Thanks for acknowledging it and sharing your thoughts. I look forward to seeing the new updates in the future.

    And yes i am using ExternalResourceClient and only considered guzzle for one of the scenario because of async calls but yes I totally agree that ExternalResourceClient is the best and preferred way.

    Thank you !!!