ufna / VaRest

REST API plugin for Unreal Engine 4 - we love restfull backend and JSON communications!
https://www.unrealengine.com/marketplace/en-US/product/varest-plugin
MIT License
1.05k stars 289 forks source link

JSON Data corrupted sometimes missing parts. #384

Closed villain-bryan closed 2 years ago

villain-bryan commented 2 years ago

Sometimes the JSON content isn't being delivered completely, making for a needle in a haystack (about 1 out of 50 attempts). Seems to happen more frequently when spamming the request, or sending a POST and a GET back and forth quickly on a keybind.

image

Expected content to receive on server:

{
        "username": "testusername",
        "password": "testpassword"
}

Bug 1:

{
        "username": "testusername",
        "password": "testpassword"

^ the above closing brace is missing (content as received on server).

Bug 2:

{
        "username": "testusername",

^ the above password and closing brace are missing (content as received on server)

No idea what is causing this. Running UE 5.1.0 at the moment and have tried the develop VaRest 5.0 and VaRest develop builds.

villain-bryan commented 2 years ago

Also want to add that there seemed to be no issues when using urlencoded instead of JSON, but that isn't a solution.

The JSON sends correctly 98% of the time, but after pressing it enough times (around 50), it breaks. Not sure if VARest is to blame, or perhaps the Netty server.

ufna commented 2 years ago

@villain-bryan , I think you should check server first. I have VaRest in few projects with different setup and client-to-server requests work as they should.

You can also try it with https://httpbin.org/post as test echo server. Will it reproduce?

villain-bryan commented 2 years ago

@villain-bryan , I think you should check server first. I have VaRest in few projects with different setup and client-to-server requests work as they should.

You can also try it with https://httpbin.org/post as test echo server. Will it reproduce?

Likely a server-side problem then. I will test in a few hours and report back with my findings.

Thank you for the speedy response!

villain-bryan commented 2 years ago

Looks like the issue was with Netty and how we were handling HttpChunks with our ChannelInitializer (not an issue with VARest).

Our solution:

ChannelPipeline p = ch.pipeline();
p.addLast(new HttpObjectAggregator(1048576)); // don't handle HttpChunks.