首页 > 解决方案 > Why does UnityWebRequest return unkown error when I do a GET request on Linux?

问题描述

This is my code:

public class DatabaseHandler : MonoBehaviour
{

    string url = "https://fakeid.firebaseio.com/";
    void Start()
    {
        StartCoroutine(GetLevelsCoroutine());
    }

    IEnumerator GetLevelsCoroutine()
    {    
        using (UnityWebRequest www = UnityWebRequest.Get(url))
        {
            www.SetRequestHeader("X-Firebase-Decoding", "1");
            yield return www.SendWebRequest();
            if (www.isDone)
            {
                Debug.Log(www.error);
                string result = www.downloadHandler.text;
                Debug.Log(result);
            }
        }
    }


}

The result variable is null and the www.error is "unknown error" I have been trying different things in order to fix this but, I just can't figure out what's causing this error, since it's just a generic error.

I have also read that this may be an unitywebrequest bug, if it is so, are there any alternatives?

标签: linuxfirebaseunity3dwebfirebase-realtime-database

解决方案


终于找到了解决问题的办法。(它只发生在某些 Linux 操作系统上)

Unity 仅正式支持 Ubuntu Linux,因此它正在寻找(但未能找到)它所期望的证书存储。您可以通过创建符号链接来解决 Fedora 问题:

mkdir -p /etc/ssl/certs && ln -s /etc/pki/tls/certs/ca-bundle.crt /etc/ssl/certs/ca-certificates.crt

这是我从中得到它的来源:https ://forum.unity.com/threads/ubuntu-headless-build-tls-handshake-fails.546704/


推荐阅读