Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

What library do you use for Rest-API calls?

Discussion in 'Multiplayer' started by umityayla, Dec 6, 2019.

  1. umityayla

    umityayla

    Joined:
    May 21, 2019
    Posts:
    26
    Hello,

    We're having issues regarding UnityWebRequests (It's slow, has different kind of bugs and weird outcomes) with Unity 2019 1.4f1. It's either because we implement it poorly or it's because it's really buggy. So I'd like to know what do you guys use for Rest API calls.
     
  2. MrsPiggy

    MrsPiggy

    Joined:
    Jun 13, 2018
    Posts:
    154
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    What kind of bugs specifically?
     
  4. umityayla

    umityayla

    Joined:
    May 21, 2019
    Posts:
    26

    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
     
    Last edited: Dec 10, 2019
  5. voncarp

    voncarp

    Joined:
    Jan 3, 2012
    Posts:
    187