Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Unanswered

Microsoft.Dynamics.Commerce.RetailProxy.IProductManager.Search - no response after 10 requests

(0) ShareShare
ReportReport
Posted on by 2
We are making up to 1000 individual and consecutive requests to Microsoft.Dynamics.Commerce.RetailProxy.IProductManager.Search with a barcode as ProductSearchCriteria to get RecoridId for each barcode. 
 
This has worked until we upgraded to v10.0.39 and now the 11th request hangs and gets no response. We send the requests and get response for 10 products and then on the request for the 11th it does not give any response, its just stuck.
 
However, when I tried to debug with Fiddler it started working and it could send 1000 request as expected. This led me to find this https://www.telerik.com/blogs/help!-running-fiddler-fixes-my-app- and it sounds like its the first type of issue mentioned here. /Ensure you always call Close() on the result of a call to GetResponseStream()./ 
 
So how can I assure that the stream or connection is closed correctly when Im using the refrences from Microsoft.Dynamics.Commerce.RetailProxy.IProductManager?
 
private async Task<Microsoft.Dynamics.Commerce.RetailProxy.Product> SearchForProductUsingBarcode(string barcode){    try    {        var productManager = await _managerFactory.GetManagerWithServerContext<IProductManager>();        var products = await productManager.Search(            new ProductSearchCriteria            {                Context = new ProjectionDomain { ChannelId = _retailServerSettings.ChannelId },                Barcodes = new ObservableCollection<string>                {                    barcode                }            },            new QueryResultSettings            {                Paging = new PagingInfo                {                    Skip = 0,                    Top = 1                },                Sorting = new SortingInfo()            }        );        return products?.FirstOrDefault();    }    catch (Exception ex)    {        Log.Error($/Error in SearchForProductUsingBarcode/, ex);        return default;    }}        public async Task<TManager> GetManagerWithServerContext<TManager>() where TManager : RetailProxyModels.IEntityManager        {            var context = await _retailContextFactory.CreateServerContextAsSystem();            return InternalGetManager<TManager>(context);        }        private TManager InternalGetManager<TManager>(RetailProxyModels.RetailServerContext context)            where TManager : RetailProxyModels.IEntityManager        {            return _container                .With((RetailProxyModels.IContext)context)                .GetInstance<TManager>();        }        public async Task<RetailServerContext> CreateServerContextAsSystem()        {            var accessToken = await _confidentialClientApplication.AcquireTokenForClient(scopes: new[] { $/{_retailServerSettings.Resource}/.default/ }).ExecuteAsync();                        return RetailServerContext.Create(                _retailServerSettings.RetailServerEndpoint,                _retailServerSettings.OperatingUnitNumber,                new ClientCredentialsToken(accessToken.AccessToken)            );        }
 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,997 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,827 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans