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) ); }