HttpWebRequest在Raspberry Pi上使用mono调用WCF服务时超时
我已经在raspberry pi模型a上安装了mono,运行Devian。 我可以使用HTTPWebRequest调用常规网页,但调用WCF服务会导致调用超时。 代码如下:HttpWebRequest在Raspberry Pi上使用mono调用WCF服务时超时,mono,timeout,raspberry-pi,system.net.httpwebrequest,Mono,Timeout,Raspberry Pi,System.net.httpwebrequest,我已经在raspberry pi模型a上安装了mono,运行Devian。 我可以使用HTTPWebRequest调用常规网页,但调用WCF服务会导致调用超时。 代码如下: using System; using System.Net; using System.IO; using System.Text; namespace TestWeb { class MainClass { public static void Main (string[] args) {
using System;
using System.Net;
using System.IO;
using System.Text;
namespace TestWeb
{
class MainClass
{
public static void Main (string[] args)
{
var r = (HttpWebRequest)WebRequest.Create ("https://eventboardstaging2.falafel.com/ConferenceService2/ConferenceListEx?dummy=634924037818870000");
r.Method = "POST";
r.ContentType = "application/json; charset=utf-8";
string json = "{\"PrivateLabel\":\"\",\"UserID\":\"46bff210-95fb-4292-8fe8-e3d99c86b97d\",\"UtcCutoff\":null}";
byte[] data = Encoding.UTF8.GetBytes(json);
using (var req = r.GetRequestStream()) {
req.Write(data, 0, data.Length);
using (var response = r.GetResponse()) {
using (StreamReader sr = new StreamReader(response.GetResponseStream())) {
var s = sr.ReadToEnd ();
Console.WriteLine (s.Substring(1,100));
}
}
}
}
}
}
堆栈跟踪是
Unhandled Exception: System.Net.WebException: The request timed out
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
at TestWeb.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.WebException: The request timed out
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
at TestWeb.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0
未处理的异常:System.Net.WebException:请求超时
0中的System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)[0x00000]处
位于:0中的System.Net.HttpWebRequest.GetResponse()[0x00000]
在TestWeb.MainClass.Main(System.String[]args)[0x00000]中:0
[错误]致命的未处理异常:System.Net.WebException:请求超时
0中的System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)[0x00000]处
位于:0中的System.Net.HttpWebRequest.GetResponse()[0x00000]
在TestWeb.MainClass.Main(System.String[]args)[0x00000]中:0
如果可能的话,请列出堆栈跟踪。好的,添加了堆栈跟踪。相同的代码在普通Mono或Windows中工作吗?是的,它在Windows中对所有版本的.net framework都有效。我在某个论坛上读到一些关于webrequest特别是WCF服务超时的信息,我忘了在哪里了。我遇到了一个类似的问题,可能是由这个bug引起的: