英文:
AWS Lambda Function (c#) - Works in debug mode, but errors occur once published
问题
我对Amazon Web Services Lambda函数还不熟悉,但我注意到您在调试模式下运行这个小函数时正常工作,但一旦发布到AWS Lambda后就失败了,出现了以下异常:
>System.Net.NetworkInformation.PingException: 在Ping请求期间发生异常。 ---> System.PlatformNotSupportedException: 未找到系统的ping实用程序。
at System.Net.NetworkInformation.Ping.SendWithPingUtility(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
at System.Net.NetworkInformation.Ping.SendPingAsyncCore(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
at System.Net.NetworkInformation.Ping.GetAddressAndSendAsync(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
--- 内部异常堆栈跟踪的结尾 ---
at System.Net.NetworkInformation.Ping.GetAddressAndSendAsync(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
at TestPingWebsite.Function.FunctionHandler(String input, ILambdaContext context) in C:\\Users\\GWhite\\source\\TestingWebsite\\TestPingWebsite\\TestPingWebsite\\Function.cs:line 26
这个错误似乎是由于系统找不到ping实用程序引起的。您可能需要检查AWS Lambda环境是否支持执行ping命令,或者尝试不使用ping来测试网站可达性的其他方法。希望这能帮助您解决问题。
英文:
I am new to Amazon Web Services Lambda functions, and I decided to write a small function to ping a website. We have a VPC subnet and security group already set up, which I applied to my function when I published it.
When I run this small function in debug mode through Visual Studio it works okay, but once I publish it to AWS Lambda it fails and I get an exception:
>System.Net.NetworkInformation.PingException: An exception occurred during a Ping request. ---> System.PlatformNotSupportedException: The system's ping utility could not be found.\n at System.Net.NetworkInformation.Ping.SendWithPingUtility(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)\n at System.Net.NetworkInformation.Ping.SendPingAsyncCore(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)\n at System.Net.NetworkInformation.Ping.GetAddressAndSendAsync(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)\n --- End of inner exception stack trace ---\n at System.Net.NetworkInformation.Ping.GetAddressAndSendAsync(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)\n at TestPingWebsite.Function.FunctionHandler(String input, ILambdaContext context) in C:\Users\GWhite\source\TestingWebsite\TestPingWebsite\TestPingWebsite\Function.cs:line 26
Can anybody help me understand why this error occurs please?
答案1
得分: 1
AWS Lambda不支持出站ICMP(驱动ping的协议)流量。除此之外,创建ping消息的基础基础设施也不受支持。
来自AWS文档(https://aws.amazon.com/lambda/faqs/):
> 问:AWS Lambda函数代码有哪些限制?
>
> Lambda尽量对正常的语言和操作系统活动施加尽可能少的限制,但有一些禁用的活动:AWS Lambda会阻止入站网络连接,而对于出站连接,只支持TCP/IP和UDP/IP套接字,以及阻止ptrace(调试)系统调用。TCP端口25的流量也被阻止,作为一项反垃圾邮件措施。
英文:
AWS lambda does not support outbound ICMP (the protocol that drives ping) traffic. In addition to this, the underlying infrastructure to create the ping messages isnt supported either.
From the AWS docs (https://aws.amazon.com/lambda/faqs/):
> Q: What restrictions apply to AWS Lambda function code?
>
> Lambda attempts to impose as few restrictions as possible on normal
> language and operating system activities, but there are a few
> activities that are disabled: Inbound network connections are blocked
> by AWS Lambda, and for outbound connections only TCP/IP and UDP/IP
> sockets are supported, and ptrace (debugging) system calls are
> blocked. TCP port 25 traffic is also blocked as an anti-spam measure.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论