dotnet version: 5.0.203 ide: JetBrain Rider
When i debug into the function, i can only see the threads in thread pool start and exit and not going into the breaking point.
All the reading and write was done by Task Async Await.
After that i tried MemoryStream, adding buffer size of reader to 40000+, and it still hangs.
Console logs: console logs
Reproduce Sample:
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace XXXXXXXX.XXXXXX.Functions
{
public static class TestFunction
{
[Function("TestFunction")]
public static async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function, "post")]
HttpRequestData req,
FunctionContext executionContext)
{
var logger = executionContext.GetLogger("TestFunction");
logger.LogInformation("C# HTTP trigger function processed a request.");
/* test01 */
// var clDataJsonStr = await new HttpRequestStreamReader(req.Body, Encoding.UTF8, 4096).ReadToEndAsync();
// var clDataJsonStr = await new HttpRequestStreamReader(req.Body, Encoding.UTF8, 4096).ReadToEndAsync();
// req.Body.Seek(0, SeekOrigin.Begin);
/* test02 */
// var serializer = new JsonSerializer();
// ClData clData;
// using (var stream = new StreamReader(req.Body, Encoding.UTF8, false, 4096))
// {
// using (JsonReader reader = new JsonTextReader(stream))
// {
// while (await reader.ReadAsync())
// {
// if (reader.TokenType != JsonToken.StartObject) continue;
// clData = serializer.Deserialize<ClData>(reader);
// logger.LogInformation(clData.ToString());
// }
// }
// }
/* test03 */
// var stringReader = new StringReader(req.Body.ToString());
// var str = await stringReader.ReadToEndAsync();
// Console.WriteLine(str);
/*test04*/
var ms= new MemoryStream();
await req.Body.CopyToAsync(ms);
var jsonBytes = ms.ToArray();
logger.LogInformation(jsonBytes.Length.ToString());
var response = req.CreateResponse(HttpStatusCode.OK);
response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
await response.WriteStringAsync("Welcome to Azure Functions!");
return response;
}
}
}
Test Json File: bycc.json