首页 > 解决方案 > IBM WATSON TEXT TO SPEECH ERROR : : 请求被中止:无法创建 SSL/TLS 安全通道

问题描述

今天我在我的 C# WPF 应用程序中使用了 ibm 云服务,它是 ibm watson 文本到语音,但是当我执行我的方法时,它显示一个异常,即请求被中止:无法创建 SSL/TLS 安全通道。

我的方法是

void Example()
        {
            IamAuthenticator authenticator = new IamAuthenticator(apikey: "{APIKEY}");
            TextToSpeechService textToSpeech = new TextToSpeechService(authenticator);
            textToSpeech.SetServiceUrl("URL");
            var result = textToSpeech.ListVoices();
            MessageBox.Show(result.Result.ToString());
        }

我不知道下一步该怎么做..因为我陷入了这个异常

标签: c#ssltext-to-speechibm-watson

解决方案


System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

在静态块中使用这行代码,如构造函数和

static System.Net.SecurityProtocolType SecurityProtocol
        {
            get;
            set;
        }

使用这种静态方法。


推荐阅读