alpaca-trade-api-csharp
alpaca-trade-api-csharp copied to clipboard
[BUG]: The decryption operation failed
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
Exception Type:
System.IO.IOException
Exception Message:
The decryption operation failed, see inner exception.
Exception StackTrace:
at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](Memory`1 buffer, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
at System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Http.HttpConnection.FillAsync(Boolean async)
at System.Net.Http.HttpConnection.Fill()
at System.Net.Http.HttpConnection.ChunkedEncodingReadStream.Read(Span`1 buffer)
at System.Net.Http.HttpBaseStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Compression.DeflateStream.ReadCore(Span`1 buffer)
at System.IO.Compression.DeflateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamReader.ReadBuffer(Span`1 userBuffer, Boolean& readToUserBuffer)
at System.IO.StreamReader.ReadSpan(Span`1 buffer)
at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)
at Newtonsoft.Json.JsonTextReader.ParsePostValue(Boolean ignoreComments)
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
at Alpaca.Markets.HttpResponseMethodExtensions.DeserializeAsync[TApi,TJson](HttpResponseMessage response)
at Alpaca.Markets.HttpResponseMethodExtensions.DeserializeAsync[TApi,TJson](HttpResponseMessage response)
at Alpaca.Markets.HttpClientExtensions.callAndDeserializeAsync[TApi,TJson](HttpClient httpClient, HttpRequestMessage request, CancellationToken cancellationToken)
at Alpaca.Markets.HttpClientExtensions.callAndDeserializeAsync[TApi,TJson](HttpClient httpClient, HttpMethod method, Uri endpointUri, CancellationToken cancellationToken)
at Alpaca.Markets.AlpacaTradingClient.ListAssetsAsync(AssetsRequest request, CancellationToken cancellationToken)
at OoplesFinanceAdminClient.AlpacaApi.GetTopLevelInfo() in E:\OoplesFinanceAdminClient\OoplesFinanceAdminClient\AlpacaApi.cs:line 2136
Exception Target Site:
MoveNext
Exception Source:
System.Net.Security
Exception HResult:
-2146232800
The specified data could not be decrypted.
Expected Behavior
Strange error and I have received this twice since so far using the latest prerelease.
Environment
- SDK Version: 6.1.1
- OS (version, bitness): Windows 10
- .NET SDK (version): 7.0 preview 7
- target process .NET version/bitness: 7.0 preview 7 x64
@OlegRa Got a bunch of these errors today and they were followed up it seems by this exception:
Exception Type:
Alpaca.Markets.RestClientErrorException
Exception Message:
internal server error occurred
Exception StackTrace:
at Alpaca.Markets.HttpResponseMethodExtensions.DeserializeAsync[TApi,TJson](HttpResponseMessage response)
at Alpaca.Markets.HttpResponseMethodExtensions.DeserializeAsync[TApi,TJson](HttpResponseMessage response)
at Alpaca.Markets.HttpClientExtensions.callAndDeserializeAsync[TApi,TJson](HttpClient httpClient, HttpRequestMessage request, CancellationToken cancellationToken)
at Alpaca.Markets.HttpClientExtensions.callAndDeserializeAsync[TApi,TJson](HttpClient httpClient, HttpMethod method, Uri endpointUri, CancellationToken cancellationToken)
at OoplesFinanceAdminClient.AlpacaApi.GetTopLevelInfo() in E:\OoplesFinanceAdminClient\OoplesFinanceAdminClient\AlpacaApi.cs:line 2182
Exception Target Site:
MoveNext
Exception Source:
Alpaca.Markets
Exception HResult:
-2146233088
@ooples According to call stack it's not an Alpaca SDK problem. I see two possible root causes:
- Problem in the .NET 7.0-preview7 networking code. Microsoft rewrote the HTTP layer in .NET 6.0 using a fully managed approach and continues to improve it. Just downgrade (if possible) to the latest stable .NET 6.0 and check if the problem persists. I'll check the .NET issues tracker for similar problem reports later this week.
- Problem with Alpaca NGNIX server and handling big responses over HTTP/2 with SSL. I've seen a similar problem before with old HTTP1.1 and it was a reason to switch into HTTP/2 in SDK but proper HTTP/2 setup on NGNIX requires some tuning for big payloads. I'll contact with Alpaca backend guys and ask about recent server configuration changes.
@OlegRa I have a strong theory that it would be the second option because I have been studying the changes to .net 7 and I haven't seen any significant changes from .net 6 to .net 7 as far as the HTTP layer goes
@ooples I'll close it now due to inactivity for a month. I'm unable to reproduce it on my side and according to the Alpaca back-end and DevOps teams nothing was changed in HTTP handling on the server side for a while. If you're still experiencing this problem, please send me logs with exact UTC timestamps as soon as possible and I'll forward them to the back-end team for checking server logs for some signs of this problem on their side.