You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I got an error connecting to redis in an AWS Lambda function on coreclr (stack trace below).
The error is triggered by the internal code that tries to optimize the socket for localhost connections on Windows, specifically the code in SocketManager.cs that tries to determine if it is running on Windows.
To verify, I copied the redis client code into my project, commented out the call to SetFastLoopbackOption (on line 178), and did not get the error when I deployed.
To fix, I'd propose adding a catch(PlatformNotSupportedException) { /* ignore */ } to the OS sniffing code to the try/catch at lines 269-280 since we don't really care if it fails.
Stack trace
One or more errors occurred. (One or more errors occurred. (Operation is not supported on this platform.)): AggregateException
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at lambda_method(Closure , Stream , Stream , ContextInfo )
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at StackExchange.Redis.ConnectionMultiplexer.ConnectImpl(Func`1 multiplexerFactory, TextWriter log)
at Zd.RefDataConsumer.Lambda.EntryPoint.LongLivedConnections.GetRedisConnectionMultiplexer() in /app/src/Zd.RefDataConsumer.Lambda/EntryPoint.cs:line 119
at Zd.RefDataConsumer.Lambda.EntryPoint.GetProcessorImpl(ILambdaContext context) in /app/src/Zd.RefDataConsumer.Lambda/EntryPoint.cs:line 52
at Zd.RefDataConsumer.Lambda.EntryPoint.<HandleKinesisRecord>d__0.MoveNext()
Operation is not supported on this platform.: PlatformNotSupportedException
at System.Runtime.InteropServices.OSPlatform.get_Windows()
at StackExchange.Redis.SocketManager.SetFastLoopbackOption(Socket socket)
at StackExchange.Redis.SocketManager.BeginConnect(EndPoint endpoint, ISocketCallback callback, ConnectionMultiplexer multiplexer, TextWriter log)
at StackExchange.Redis.PhysicalConnection.BeginConnect(TextWriter log)
at StackExchange.Redis.PhysicalBridge.GetConnection(TextWriter log)
at StackExchange.Redis.ServerEndPoint..ctor(ConnectionMultiplexer multiplexer, EndPoint endpoint, TextWriter log)
at StackExchange.Redis.ConnectionMultiplexer.<ReconfigureAsync>d__123.MoveNext()
Investigation Details
I had trouble believing a call to get the OSPlatform.Windows property would ever fail, so I deployed this code in a lambda function to verify:
facepalm
System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Runtime.InteropServices.OSPlatform.get_Windows()
at Zd.Availability.ProfessionalRefData.Lambda.EntryPoint.HandleDerp(String ignoreInput)
So I stand corrected. For anyone interested in writing an AWS lambda function, here's their framework and documentation
I am successfully using the redis client in an AWS ECS task (running in the microsoft dotnet core docker image). It uses the same connection logic as my lambda, and there are no issues.
The differences between the two environments are:
AWS Lambda is dotnet core 1.0, while my docker image is 1.1
AWS Lambda runs on Amazon linux while my docker image is debian
Originally I thought this error was related to dotnet core 1.0.x but I ran my test code on the older docker images for 1.0.x and they all worked, suggesting the problem is somehow with Amazon Linux.
The text was updated successfully, but these errors were encountered:
I got an error connecting to redis in an
AWS Lambda
function oncoreclr
(stack trace below).The error is triggered by the internal code that tries to optimize the socket for localhost connections on Windows, specifically the code in SocketManager.cs that tries to determine if it is running on Windows.
To verify, I copied the redis client code into my project, commented out the call to
SetFastLoopbackOption
(on line 178), and did not get the error when I deployed.To fix, I'd propose adding a
catch(PlatformNotSupportedException) { /* ignore */ }
to the OS sniffing code to thetry/catch
at lines 269-280 since we don't really care if it fails.Stack trace
Investigation Details
I had trouble believing a call to get the
OSPlatform.Windows
property would ever fail, so I deployed this code in a lambda function to verify:When I tested in the aws console I got
So I stand corrected.
For anyone interested in writing an AWS lambda function, here's their framework and documentation
I am successfully using the redis client in an AWS ECS task (running in the microsoft dotnet core docker image). It uses the same connection logic as my lambda, and there are no issues.
The differences between the two environments are:
dotnet core 1.0
, while my docker image is1.1
Amazon linux
while my docker image isdebian
Originally I thought this error was related to
dotnet core 1.0.x
but I ran my test code on the older docker images for1.0.x
and they all worked, suggesting the problem is somehow withAmazon Linux
.The text was updated successfully, but these errors were encountered: