在Linux上执行GET请求时,为什么UnityWebRequest返回未知错误? [英] Why does UnityWebRequest return unkown error when I do a GET request on Linux?

查看:258
本文介绍了在Linux上执行GET请求时,为什么UnityWebRequest返回未知错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

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);
            }
        }
    }


}

结果变量为null,而www.error为未知错误" 为了解决这个问题,我一直在尝试不同的方法,但是,我只是不知道是什么原因导致了此错误,因为这只是一个一般性错误.

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.

我还读到这可能是一个unitywebrequest错误,如果是这样,还有其他选择吗?

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

推荐答案

最终找到了解决问题的方法. (仅在某些Linux操作系统上发生)

Finally found the solution to the problem. (It only occurs on some Linux OS)

Unity仅正式支持Ubuntu Linux,因此它正在查找(但找不到)证书存储所在的位置.您可以通过创建符号链接来解决Fedora:

Unity only officially supports Ubuntu Linux, so it is looking (and failing to find) the certificate store where it would expect it to be. You can work around on Fedora by creating a symbolic link:

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

这是我从以下来源获得的资源:

This is the source where I got it from: https://forum.unity.com/threads/ubuntu-headless-build-tls-handshake-fails.546704/

这篇关于在Linux上执行GET请求时,为什么UnityWebRequest返回未知错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆