2012-12-27 18 views
19

にサーバーによって閉じられた接続がasp.net

注:Even the connection is open and it is fine.

The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException : The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.

ソースエラー:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

スタックトレース

[WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.] 
    Effrtpartsigndone.Page_Load(Object sender, EventArgs e) +8196 
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 
    System.Web.UI.Control.OnLoad(EventArgs e) +91 
    System.Web.UI.Control.LoadRecursive() +74 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207 

バージョン情報:Microsoft .NET Frameworkバージョン:4.0.30319;

ASP.NETのバージョン:4.0.30319.272

+1

ページ**ソースコード** plsは –

答えて

7

このMSDNの記事は、似たような状況を説明しているようです。それはあなたの問題に一致した場合、私たちは知ってみましょう:

http://social.msdn.microsoft.com/forums/en-US/netfxnetcom/thread/246ffc07-1cab-44b5-b529-f1135866ebca/

引用:

[...].Net is sending first Expect 100 in one senddata of socket then send the actual request. Server Responds back with Continue 100. And exactly here .Net is showing message "Underlying connection was close. Connection was closed unexpectedly".

.Net is under impression that it has anyway already sent the data but server sent Connection : Close so it shows error without resending(sic) the request.

So the solution for the above that worked for me was

System.Net.ServicePointManager.Expect100Continue = False 

あなたはinterlopers間のトラフィックを確認したい場合は、Wiresharkのまたは同様のツールとのHTTP交換をスヌープ。

+0

:それは私のcase.Anywayはありませんが、お返事に感謝。 – MahaSwetha

2

私はこのように構成していた:

ServicePointManager.DefaultConnectionLimit = 100; 

私はエラーが離れていった、ということ取り除かたら。

0

戻ってきたオブジェクトグラフにループがありました。私はおそらくあなたの問題ではないことを知っていますが、他の誰かが同じ問題を抱えている場合に備えてここに追加しています。 IncludeExceptionDetailInFaultsが有効になっていましたが、どのクライアント(アプリケーションまたはWCFテストクライアント)でもエラーが発生していませんでした。幸いにも、それはサーバーログに現れたので、私たちはそれをそのように見つけることができました。

私たちは、2方向のナビゲーションのためのparent -> childchild -> parentを持っていた、エラーが去っていきました、私たちはそのリンクを解除し、代わりにparent -> childを持っていた、と子供は親をルックアップするためのIDを持っていました。

これが誰かを助けることを願っています!

1

私は同じ問題を抱えていたとserviceBehaviors要素で、サーバの設定に

<serviceBehaviors> 
    <behavior name="ServiceBehaviour"> 
     ... 
     <dataContractSerializer maxItemsInObjectGraph="6553500"/> 
     ... 
    </behavior> 
</serviceBehaviors> 

を設定するには、問題を解決しました。

トレースは、これらの問題の根本を見つけることに多くのことができます:私の場合はhttps://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx

0

、問題がファイルの長さです。あなたのサーバー上の許可されたファイルサイズを確認してください。スクリプトではちょうどこの部分チェックを実行します。

dataStream.Write(filesBytesArray, 0, filesBytesArray.Length); 
dataStream.Close(); 

をそして、あなたが知らない場合は、ちょうどあなたのフロントエンド部分のIEでファイルアップロードサイズを制限します。HTML <input type="file">アップロード要素、これはgood reference for limiting file size and other filterです。

5

おそらく、クライアントのタイムアウトがサーバーのタイムアウトよりも大きいためです。サーバーは接続を閉じ、クライアントは依然として応答を待っているか、要求を送信しています。

KeepAliveプロパティをFalseに設定すると、接続が自動的に閉じられ、すべての要求に対して再度開くようにする必要があります。 これにより、閉じた接続を使用しようとする問題を回避できます。

1

RestSharpライブラリを使用しているときも同じ問題がありました。私はRestClientオブジェクトを作成する前に、次の2行を追加することで解決:

ServicePointManager.DefaultConnectionLimit = 100; 
ServicePointManager.MaxServicePointIdleTime = 5000;