单声道的Apache2的HttpWebRequest与&QUOT崩溃;请求超时" [英] Mono Apache2 HttpWebRequest crashes with "The request timed out"

查看:130
本文介绍了单声道的Apache2的HttpWebRequest与&QUOT崩溃;请求超时"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用我的ASP.Net应用程序的支付网关API。当MonoDevelop中使用XSP测试应用程序的工作原理。当我将其配置在同是mod_mono的code保持与超时错误崩溃的Apache2运行。

I am using a payment gateway API in my ASP.Net application. When testing in MonoDevelop with XSP the application works. When I configure it to run in apache2 with mod_mono the code keeps crashing with a timeout error.

我难倒,以什么可以与Apache中,而不是XSP托管改变。反正下面是code是超时:

I am stumped as to what could change with hosting in Apache instead of XSP. Anyways below is the code that is timing out:

private string SubmitXml(string InputXml)
{
    HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(_WebServiceUrl);
    webReq.Method = "POST";

    byte[] reqBytes;

    reqBytes = System.Text.Encoding.UTF8.GetBytes(InputXml);
    webReq.ContentType = "application/x-www-form-urlencoded";
    webReq.ContentLength = reqBytes.Length;
    webReq.Timeout = 5000;
    Stream requestStream = webReq.GetRequestStream();
    requestStream.Write(reqBytes, 0, reqBytes.Length);
    requestStream.Close();

    HttpWebResponse webResponse = (HttpWebResponse)webReq.GetResponse();
    using (StreamReader sr = new StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.ASCII))
    {
        return sr.ReadToEnd();
    }
}

在code崩溃就行了:流requestStream = webReq.GetRequestStream();

返回的错误是:

请求超时

说明:HTTP 500错误处理请求

Description: HTTP 500. Error processing request.

堆栈跟踪:

System.Net.WebException:请求超时的
  System.Net.HttpWebRequest.GetRequestStream()[0x0005f]在
  /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net/HttpWebRequest.cs:746
  在TCShared.PxPay.SubmitXml(System.String InputXml)[0x00048]中
  /Users/liam/Projects/techcertain/techcertaincsharp/Components/TCShared/PaymentGateways/Client/PxPay.cs:85
  在TCShared.PxPay.GenerateRequest(TCShared.RequestInput输入)
  [0x00015]中
  /Users/liam/Projects/techcertain/techcertaincsharp/Components/TCShared/PaymentGateways/Client/PxPay.cs:69

System.Net.WebException: The request timed out at System.Net.HttpWebRequest.GetRequestStream () [0x0005f] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net/HttpWebRequest.cs:746 at TCShared.PxPay.SubmitXml (System.String InputXml) [0x00048] in /Users/liam/Projects/techcertain/techcertaincsharp/Components/TCShared/PaymentGateways/Client/PxPay.cs:85 at TCShared.PxPay.GenerateRequest (TCShared.RequestInput input) [0x00015] in /Users/liam/Projects/techcertain/techcertaincsharp/Components/TCShared/PaymentGateways/Client/PxPay.cs:69

在我的web.config我有以下的请求超时:

In my Web.Config I have the following as the request timeout:

<httpRuntime executionTimeout="43200" maxRequestLength="104856" requestValidationMode="2.0"  />

我曾尝试在改变超时值的HttpWebRequest但它仍然是超时。

I have tried changing the Timeout value on the HttpWebRequest but it still is timing out.

是什么原因造成这种情况发生,我怎么能解决这个问题?

What is causing this to happen and how can I fix it?

推荐答案

我设法找出原因,我遇到了这个问题。这是完全无关的使用Apache的。

I managed to find out why I was experiencing this problem. It is completely unrelated to the use of Apache.

我使用Npgsql数据库访问到PostgreSQL。 Npgsql带有两个DLL(Npgsql.dll和Mono.Security.dll)。对于一些未知的原因Mono.Security.dll导致的HttpWebRequest在Mono运行时超时。

I am using Npgsql for database access to Postgresql. Npgsql comes with two dlls (Npgsql.dll and Mono.Security.dll). For some unknown reason Mono.Security.dll causes the HttpWebRequest to timeout when running on Mono.

不管怎么说Mono上运行时,因为它已经包含在单框架不需要Mono.Security.dll。所以从我的bin目录中删除Mono.Security DLL后的HttpWebRequest的,现在的工作。

Anyways Mono.Security.dll isn't needed when running on Mono because it is already included in the Mono framework. So after removing the Mono.Security dll from my bin directory HttpWebRequest's are now working.

全部归功于这个帖子在这里<一个href=\"http://mono.1490590.n4.nabble.com/The-request-timed-out-at-HttpWebRequest-EndGetResponse-td2218213.html\">http://mono.1490590.n4.nabble.com/The-request-timed-out-at-HttpWebRequest-EndGetResponse-td2218213.html

Full credit goes to this post here http://mono.1490590.n4.nabble.com/The-request-timed-out-at-HttpWebRequest-EndGetResponse-td2218213.html .

这篇关于单声道的Apache2的HttpWebRequest与&QUOT崩溃;请求超时&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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