I use AmazonDynamoDBClient in the lambda to remove/insert an item into the dynamodb once the message arrives into the queue. Here is the code for delete operation
var request = new DeleteItemRequest()
{
TableName = _tableName,
Key = new Dictionary<string, AttributeValue>()
{
{ "Id", new AttributeValue() { S = id } }
}
};
await _client.DeleteItemAsync(request);
_client is set up as singleton in my DI container as well as the repository class communicating with dynamodb.
During load tests (around 1000 messages for 1 minute), it was found out that sometimes I might receive an exception SSLStream: ObjectDisposedException
One or more errors occurred. (Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.) (Cannot access a disposed object.
Object name: 'SslStream'.) (Cannot access a disposed object.
Object name: 'SslStream'.) (Cannot access a disposed object.
Object name: 'SslStream'.) (Cannot access a disposed object.
Object name: 'SslStream'.) ---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.
at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)
at Amazon.Runtime.Internal.HttpHandler`1.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)
at MyLambda.Repository.........
The same issue for insert btw
I watched at DynamoDb metrics: latency is really low (10ms) and no errors. Is there anything I can try to do regarding this to fix the issue and avoid such errors?