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

Bug UnityWebRequest connection reuse broken

Discussion in 'Android' started by todans, Dec 9, 2021.

  1. todans

    todans

    Joined:
    Mar 4, 2014
    Posts:
    12
    Seems like after Unity 2020.3.9 update connection reuse on Android is broken. I made simple test project with one button making http request.
    Code (csharp):
    1. private IEnumerator ReqRoutine(string url)
    2.     {
    3.         var req = new UnityWebRequest(url);
    4.         var op = req.SendWebRequest();      
    5.         yield return op;
    6.         _txt.text = op.webRequest.responseCode.ToString();
    7.         req.Dispose();
    8.     }
    I built it wih Unity 2020.3.8 and, as expected, fiddler showed that when I made a series of requests (10 in a row) they all used the same connection. After that I tried several builds with different Unity versions (including 2021.2.5f) and all of them showed the same behaviour: every request starts new connection. So, I have one active connection in version 2020.3.8, but starting with 2020.3.9 I have 5 active connections (size of connection pool?) and no connection reuse.

    Is this an expected behaviour or not? Is there a way to make UnityWebRequest reuse connections on Android? Or maybe I'm doing something wrong? ))
     
    Last edited: Dec 10, 2021
  2. tmars

    tmars

    Joined:
    Jul 26, 2013
    Posts:
    42
    I second that, keep-alive is badly broken since 2020.3.9.