私は今プロキシを設定するのに楽しい時間を過ごしました。現時点で私は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"
に関連する2つのエントリがあります。
これは私の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