0

I have a REST API services application that is using Asp.net core, and hosted on Azure App Service. I am adding Azure Redis as a cache mechanism.

I tested the application on my local machine using local redis and it is working fine. I deployed the Web service To Azure App Service, and test it.

When I try to test the services using Postman, it is working fine, and it is populating the cache, and reading from the cache.

But when I run the Front-end application which is a JavaScript Single Page Application that is calling the back-end services.

I am not querying Redis from the front-end. but from the backend .net application.

The calls to the services fail with this error

Timeout performing EVAL, inst: 1, 
clientName: <.....>, serverEndpoint: Unspecified/my-redis.redis.cache.windows.net:6380, 
keyHashSlot: 15126 (Please take a look at this article for some common client-side issues that can cause timeouts: http://stackexchange.github.io/StackExchange.Redis/Timeouts)

As I said, I am calling the same EndPoint (which is my App service), with the same parameters, from Postman, and it is working. But from the browser, it is not working

This is my configuration and code:

In the Startup.cs

public void ConfigureServices(IServiceCollection services)
{
  ...
   services.AddDistributedRedisCache(options => {
                options.Configuration = Configuration.GetConnectionString("AzureCache");
                options.InstanceName = "master";
                });
}

And in the controller (ProductController)

using Microsoft.Extensions.Caching.Distributed;
public class ProductController: ControllerBase
{
   IDistributedCache _cashe;
   IDataRepository _repo;
   public ProductController (IDistributedCache cache, IDataRepository repo)
   {
       _cache = cache;
       _repo = repo;
   }

   [HttpGet]
   public Async Task<IActionResult> GetProductions([FormBody] DataRequest request)
   {
      string data = _cache.GetString(request.AsKey());
      if (data == null)
      {
           data = _repo.getData(request);
           _cache.SetString(request.AsKey());
      }
      return Ok(data);
   }
}

}

The client side code is as follows:

const request = axios.post('https://mydata.myserver.azure.com', reqBody, headers);
request.then(res => {
    .... process the data
});

P.S: the error mentioned an article online. I read the article and nothing jumped out. All my services are less than 5k in size except one, which is between 250k and 300k, and all calls are failing for me.

Ghassan Karwchan
  • 3,355
  • 7
  • 37
  • 65

1 Answers1

0

Error itself describing 'Please take a look at this article for some common client-side issues'. Could you share your client side code through which you are making call?

  • I added the client side script. I read that post mentioned in the error, but didn't find anything related to mine. My json return is less than 5k for all services, except for one which is 250k to 300k. – Ghassan Karwchan Dec 30 '19 at 15:49