2

ServiceStack サービス (現時点では HTTP リスナーを使用してスタンドアロンで実行) に対して POST および PUT 要求を行うと、要求が機能することがあり、クライアント (HTTPie) がハングすることがあります。しばらくすると、Visual Studio の [出力] ウィンドウにいくつかの情報が表示されます:-

A first chance exception of type 'System.Net.HttpListenerException' occurred in System.dll
A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in ServiceStack.dll
A first chance exception of type 'System.Net.HttpListenerException' occurred in System.dll
A first chance exception of type 'System.Net.HttpListenerException' occurred in ServiceStack.dll
A first chance exception of type 'System.Net.HttpListenerException' occurred in ServiceStack.dll
A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in ServiceStack.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll

ServiceStack で組み込みのロギングを有効にすると、詳細が表示されました:-

ERROR: Error occured while Processing Request: Could not deserialize 'application/json; charset=utf-8' 
   request using WebServices.Dto.Country'
Error: System.Net.HttpListenerException (0x80004005): The I/O operation has been aborted because of either
    a thread exit or an application request
  at System.Net.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 size)
  at System.IO.StreamReader.ReadBuffer()
  at System.IO.StreamReader.ReadToEnd()
  at ServiceStack.Text.JsonSerializer.DeserializeFromStream(Type type, Stream stream) in C:\src\ServiceStack.Text\
   src\ServiceStack.Text\JsonSerializer.cs:line 164
  at ServiceStack.ServiceModel.Serialization.JsonDataContractDeserializer.DeserializeFromStream(Type type, Stream 
   stream) in C:\src\ServiceStack\src\ServiceStack.Common\ServiceModel\Serialization\JsonDataContractDeserializer.cs:line 86
  at ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.CreateContentTypeRequest(IHttpRequest httpReq, 
   Type requestType, String contentType) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\Support\
   EndpointHandlerBase.cs:line 100, 
Exception: Could not deserialize 'application/json; charset=utf-8' request using WebServices.Dto.Country'
Error: System.Net.HttpListenerException (0x80004005): The I/O operation has been aborted because of either a thread
   exit or an application request
  at System.Net.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 size)
  at System.IO.StreamReader.ReadBuffer()
  at System.IO.StreamReader.ReadToEnd()
  at ServiceStack.Text.JsonSerializer.DeserializeFromStream(Type type, Stream stream) in C:\src\ServiceStack.Text\src\
   ServiceStack.Text\JsonSerializer.cs:line 164
  at ServiceStack.ServiceModel.Serialization.JsonDataContractDeserializer.DeserializeFromStream(Type type, Stream 
   stream) in C:\src\ServiceStack\src\ServiceStack.Common\ServiceModel\Serialization\JsonDataContractDeserializer.cs:line 86
  at ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.CreateContentTypeRequest(IHttpRequest httpReq, 
   Type requestType, String contentType) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\Support\EndpointHandlerBase.cs:line 100
ERROR: Could not WriteTextToResponse: An operation was attempted on a nonexistent network connection, Exception: 
   An operation was attempted on a nonexistent network connection
ERROR: Could not WriteTextToResponse: An operation was attempted on a nonexistent network connection, Exception: 
   An operation was attempted on a nonexistent network connection
INFO: Failed to write error to response: {0}, Exception: An operation was attempted on a nonexistent network connection

私は次のようなテストリクエストを作成しています:-

http --json post "http://localhost:1337/countries/" DefaultHouse_Id=2 Name=Denmark

この正確な試みは、うまくいく場合もあれば失敗する場合もあります。NuGet の最新の ServiceStack を .NET4 と VS 2010 で使用しています。リクエストが自分のコードにまったく到達していないようです。

これを引き起こす原因、またはデバッグ方法を知っている人はいますか?

編集:それが関連しているかどうかはわかりませんが、時々これも取得します:-

{

"ResponseStatus":{

 "ErrorCode":"TypeLoadException",
 "Message":"Could not load type 'ServiceStack.ServiceInterface.HttpRequestApplyToExtensions' from assembly 'ServiceStack.ServiceInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.",
"StackTrace":"   at RulesLayer.AuditFilterAttribute.Execute(IHttpRequest req, IHttpResponse res, Object requestDto)\n   at     ServiceStack.ServiceInterface.RequestFilterAttribute.RequestFilter(IHttpRequest req, IHttpResponse res, Object requestDto) in C:\\src\\ServiceStack\\src\\ServiceStack.ServiceInterface\\RequestFilterAttribute.cs:line 41\n   at ServiceStack.WebHost.Endpoints.EndpointHost.ApplyRequestFilters(IHttpRequest httpReq, IHttpResponse httpRes, Object requestDto) in C:\\src\\ServiceStack\\src\\ServiceStack\\WebHost.Endpoints\\EndpointHost.cs:line 303\n   at ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) in C:\\src\\ServiceStack\\src\\ServiceStack\\WebHost.Endpoints\\RestHandler.cs:line 63"
}

}
4

2 に答える 2

3

AVGアンチウイルスビジネスが原因のようです。ウイルス対策ソフトウェアが嫌いな理由があることはわかっていました。

コードが別のマシンで正常に機能していることを発見しました。これは、開発ボックスのセットアップに固有のものであることがわかりました。マシンを最小限に戻し、未使用のソフトウェア、VS拡張機能、プラグインなどを削除してみました。ServiceStackのIISExpressモードとセルフホストモードの両方を試しました。Dropboxからコードを移動してみました。何も違いはありませんでした。

私がついにAVGを無効にしたとき、問題はちょうど消え、数時間後も完全に機能しています。

于 2012-09-28T10:08:27.950 に答える
1

デバッグするには、プロジェクトのソースコードをダウンロードし、フレームワークのソースコード自体をデバッグすることに勝るものはありません。統合テストでこの動作を再現して、原因を特定することをお勧めします。これを行う方法の例については、ServiceStackのhttpリスナー統合テストを参照してください。

ServiceStackでのログインを有効にするには、AppHostを開始/初期化する前に、ログファクトリを選択したプロバイダーに設定する必要があります。

LogManager.LogFactory = new ConsoleLogFactory(typeof(Program));
于 2012-09-26T17:27:41.160 に答える