HAProxy community

Issues Regarding Communication Between Unity and REST API Server

Hello,

I’m a system administrator/back-end developer in a small sized mobile gaming studio who’s creator of Real Car Parking 2 with 40+ millions of downloads and we’re having a couple of issues regarding communication between Unity game client(s) and our Rest-API server. Issues we currently suffer are down below;

1-It sometimes takes too much for a request to complete. For example a simle API request (POST) usually takes 300-400 ms. But sometimes it takes up to 10 seconds and it actually sometimes time outs. Weird part over here is that it even takes too much time that sometimes when working with local API and local client it sometimes takes 1 second for a request to complete. But when I try the same post request over Postman, I always get around 100-150 ms (300 ms at worst) response time.

2-We sometimes receive “Unknown Error” from Rest API calls. When we trace it back to adb we see the error “java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.” and we get this error time to time. For example; we get this error, then a few seconds later when we send another request it doesn’t have any problem.

3-We also have problems regarding iPhone devices. When they try to post a request with a JSON body bigger than around 25-30 KBs, server receives it corrupted. Entire JSON body looks like garbage and because of that player receives 400 Bad Request error. Weird part here is that clients don’t have any problem with parsing JSON body bigger than 25-30 KBs from server.

Our specifications are like this;

On server we have Haproxy + uWSGI + Flask (We use Let’s Encrypt for SSL)
On clients, we have Unity 2019 1.4f1 + proyecto26 Rest Client (https://github.com/proyecto26/RestClient) (Which uses UnityWebRequests)

Here the Haproxy statistics for an unusual request that we’re trying to solve;
Dec 10 13:58:01 localhost.localdomain haproxy[4469]: client_address = “*", path = "”, status = 200, Tr=31, Tw=0, Tc=0, Ta=31, sslVersion=“TLSv1.3”, Tt=4112, Td=0, Th=4081, Ti=0, Tq=4081, TR=0
Tr => response time
Tw => total time spent in the queues waiting for a connection slot.
Tc => time to establish TCP connection to server
Ta => active time of requests (from %TR to end)
Tt => total session duration time
Td => Tt – (Tq + Tw + Tc + Tr)
Th => connection handshake time (SSL, PROXY protocol)
Ti => idle time before the HTTP request
Tq => time to get the client request
Tr => time to receive the full request from first byte

We also sometimes receive “frontend_https/1: SSL handshake failure” errors commonly…

I’d be really glad to receive back from you. Whether you had any problems regarding this issue or you solved it anyway. Or I’d love to receive any kind of feedback from you. Have a nice day!