Issue
I’m experiencing a very weird intermittent issue with my API calls. Sometimes the response gets truncated.
- There isn’t a pattern for how or when it gets truncated.
- Response size is 200kb and configured response limit is 20mb.
Formatters configuration:
private static HttpConfiguration ConfigureFormatters(this HttpConfiguration config)
{
config.Formatters.Clear();
config.Formatters.Add(new JsonMediaTypeFormatter());
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
return config;
}
Simplified Api call:
[HttpGet, Route]
public IHttpActionResult Explore(int cityId)
{
var lists = exploreBuilderService.Build(cityId);
return Ok(lists);
}
lists
type is List<SomeModel>
. SomeModel
is DTO
with no circular references.
Sample response:
Response Headers
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Fri, 17 Jan 2020 12:02:37 GMT
Content-Length: 290248
Data
[..., {"id":47
...
are other objects in the array.
It looks like json response string is cut in a random place. Our android application fails with MalformedJsonException
when the response comes like this. It happens once on like 5-10 requests for the same data set.
Did you encounter a problem like this? Where should I look for potential problems causing this?
Solution
The issue was with one of our middlewares which did response interception.
Answered By – Marko Marinovic
Answer Checked By – Willingham (BugsFixing Volunteer)