If debug mode is enabled on server and request object sent from JsonServiceClient is large (List of 1000 items) then error message is not properly deserialized from responseStatus and everytime is “The request was aborted: The connection was closed unexpectedly.”
Problem is in StackTrace size - when debug mode is false (and StackTrace is not sent) then everything is OK.
at ServiceStack.Net40PclExport.GetResponse(WebRequest webRequest)
at ServiceStack.ServiceClientBase.Send[TResponse](String httpMethod, String relativeOrAbsoluteUrl, Object request)
at ServiceStack.ServiceClientBase.Post[TResponse](IReturn`1 requestDto)
Please provide a stand alone example we can run to repro the issue. I will add .NET’s HttpWebRequest is a completely different implementation in .NET Core where it’s retrofitted on top of HttpClient, so can you let me know if you still have the issue when using JsonHttpClient.
This appears to be a bug in .NET’s HttpWebRequest (originating back to 2005) where the only config I’ve found that prevents aborting the connection is to change the protocol version back to HTTP 1.0, which you can do in a global Request Filter for all requests with:
It is not big problem when I know what is wrong. I just turn off debug to check my exceptions or maybe I will switch to JsonHttpClient.
Problem was when I thought that my code is causing this.
Since JsonHttpClient does not have action OnAuthenticationRequired is there recommended way to reauthenticate client on session expire or server reset?
I am using custom CredentialsAuthProvider and storing my sessions in memory for now.
I have tried to override Send method and on HttpError 400 reauthenticate user and send request again, but not sure which one needs to be overridden to have all situations covered (sync, async, POCO dtos, streams…)?