繁体   English   中英

使用 .net/c# 通过代理连接到 Watson DiscoveryService

[英]Connect to Watson DiscoveryService through a proxy using .net/c#

使用 C# 在公司代理后面时无法连接到 Watson Discovery Service

我阅读了文档,并在线搜索,但仅引用了基于 NodeJS 的实现。 也有人在寻找相同问题的解决方案,但使用 Java,提出的是扩展当前的 api 以添加支持代理的方法。

 IamAuthenticator authenticator = new IamAuthenticator(
     apikey: "{apikey}"
     );

 DiscoveryService discovery = new DiscoveryService("2019-04-30", authenticator);
 discovery.SetServiceUrl("{url}");

 var result = discovery.CreateEnvironment(
     name: "my_environment",
     description: "My environment"
     );

 Console.WriteLine(result.Response);

上面的代码直接用于文档,只要我不在代理后面,它就可以正常工作。 我想知道我是否遗漏了什么或 Watson .net SDK 不支持代理。 我已经在 IBM 开发者论坛上问过了,但没有答案。

您是否尝试设置代理参数? 这是 python 版本,但也许

proxies={'proxies.https' : 'your_proxy', 'proxies.http' : 'your_proxy'}

您应该能够通过http_proxyhttps_proxy环境变量设置代理。 您可以在应用程序环境中使用

set http_proxy=http://proxy.server.com:3128

来自 cmd。

您也可以在应用程序中使用

Environment.SetEnvironmentVariable("http_proxy", "http://proxy.server.com:3128");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM