지금 프록시를 구성하는 데 많은 시간을 할애했습니다. 지금은 proxybonanza라는 서비스를 사용합니다. 그들은 웹 페이지를 가져 오는 데 사용하는 프록시를 제공합니다.프록시는 로컬에서는 작동하지만 웹 호스트에 업로드하면 실패합니다.
내가 프록시없이 내 코드를 실행하면 내가 지금 HTMLAGILITYPACK
을 사용하고 웹 호스트 서버에 업로드 로컬 또는 아무 문제가 없습니다.
프록시를 사용하기로 결정하면 다소 오래 걸리지 만 여전히 로컬로 작동합니다.
If I publish my solution to, to my webhost I get a SocketException (0x274c)
"A connection attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because connected host has
failed to respond 38.69.197.71:45623"
나는 이것을 오랫동안 디버깅 해왔다.
내의 app.config는 몇 가지 문제를 통해 나에게 도움이
httpWebRequest useUnsafeHeaderParsing="true"
httpRuntime executionTimeout="180"
관련있는 두 개의 항목이 있습니다.
이제 내 C# 코드입니다.
HtmlWeb htmlweb = new HtmlWeb();
htmlweb.PreRequest = new HtmlAgilityPack.HtmlWeb.PreRequestHandler(OnPreRequest);
HtmlDocument htmldoc = htmlweb.Load(@"http://www.websitetofetch.com,
"IP", port, "username", "password");
//This is the preRequest config
static bool OnPreRequest(HttpWebRequest request)
{
request.KeepAlive = false;
request.Timeout = 100000;
request.ReadWriteTimeout = 1000000;
request.ProtocolVersion = HttpVersion.Version10;
return true; // ok, go on
}
내가 뭘 잘못하고 있니? appconfig에서 추적 기능을 활성화했지만 웹 호스트에 로그온하지 않았습니다 ...?
Log stuff from app.config
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing" >
<listeners>
<add name="ServiceModelTraceListener"/>
</listeners>
</source>
<source name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
<listeners>
<add name="ServiceModelTraceListener"/>
</listeners>
</source>
<source name="System.Runtime.Serialization" switchValue="Verbose,ActivityTracing">
<listeners>
<add name="ServiceModelTraceListener"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="App_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp"/>
</sharedListeners>
</system.diagnostics>
아무도 내가이 천 번 식으로 설정하고 해제 한 문제 ..
request.KeepAlive = false;
System.Net.ServicePointManager.Expect100Continue = false;
칼을 발견 할 수
앱 구성에서 웹 요청을 허용 했습니까? 또는 mimetype을 허용하는 것을 잊었습니까? 어떤 종류의 서버를 호스팅하고 있습니까? – wegginho
@wegginho Im 공유 호스트에 있습니다.VPS는 asp.net 4.0 플랫폼의 표준 웹 호스팅 계정입니다. – 8bitcat
그건 절대 좋아. web.config 내에서 일반적으로 수행하는 모든 설정을 IIS에 수행 할 수 있습니다. 약간의 차이점은 web.config를 저장하거나 게시 할 때마다 응용 프로그램이 다시 시작된다는 것입니다. – wegginho