我正在将YoutubeExplode与代理一起从youtube.com下载视频。
public async Task<ApiResult<List<videoList>>> Search(string videoName)
{
var res= new ApiResult<List<videoList>>(0,null,null);
//set proxy
HttpClientHandler handler = new HttpClientHandler()
{
Proxy = new WebProxy("myvps:port",false),
UseProxy = true
};
using (var client = new HttpClient(handler))
{
YoutubeClient youtubeclient = new YoutubeClient(client);
var list=await youtubeclient.SearchVideosAsync(videoName, 2);
//convert
res.data = list.ToVideoList();
}
return res;
}
由于GFW,我带来了一个VPS,安装了Squid(一个http代理服务器)并像这样在Ubuntu16.04上简单地对其进行了配置
bash:“ sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.original”
bash:“ vim /etc/squid/squid.conf”
http_port 3128
http_access allow all
bash:“ systemctl重新启动squid.service”
在那之后,当我运行WebApi时,我得到了错误消息:
<ExceptionMessage>
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
</ExceptionMessage>
我查看了鱿鱼日志
1563595921.406 2 117.152.169.17 TAG_NONE/500 0 CONNECT youtube.com:443 - HIER_DIRECT/172.217.5.78 -
1563595921.708 0 117.152.169.17 TAG_NONE/500 0 CONNECT youtube.com:443 - HIER_DIRECT/172.217.5.78 -
1563596804.825 3 117.152.169.17 TAG_NONE/500 0 CONNECT youtube.com:443 - HIER_DIRECT/172.217.14.110 -
1563596805.076 0 117.152.169.17 TAG_NONE/500 0 CONNECT youtube.com:443 - HIER_DIRECT/172.217.14.110
我想知道我的配置文件是否有问题。
所以我尝试了bash:“ curl -x vps_ip:port -L https://www.youtube.com”,但它似乎奏效了。
查看日志
1563599971.588 2930 xxx_xxx_xxx_xxx TCP_TUNNEL/200 385942 CONNECT www.youtube.com:443 - HIER_DIRECT/172.217.14.110 -
请帮忙!
答案 0 :(得分:0)
很抱歉,如果这个答案没有帮助。但是我遇到了WCF异步调用的类似问题。基本上我所做的是我对服务进行了异步调用,而我没有等待结果。最终阻止了我的视线,隐藏了一个紧密的连接。所以发生了什么事,因为该调用是异步调用,所以我可能在执行完成之前就关闭了该调用。