hi guys , i have a lambda function that call an externale Soap Api, if i launch in local all work good , but if i test in lambda i have this error:
2023-04-16T13:30:43.956Z d405592c-2d8b-445a-a41a-7075de51104c fail System.Net.WebException: The operation has timed out.
at System.Net.HttpWebRequest.GetResponse()
at System.Net.WebClient.GetWebResponse(WebRequest request)
at System.Net.WebClient.OpenRead(Uri address)
at System.Net.WebClient.OpenRead(String address)
at SoapApiCall.Function.FunctionHandler(ILambdaContext context) in C:\Users\giacomo.carcano\.aws\SoapApiCall\src\SoapApiCall\Function.cs:line 23
at lambda_method1(Closure , Stream , ILambdaContext , Stream )
at Amazon.Lambda.RuntimeSupport.Bootstrap.UserCodeLoader.Invoke(Stream lambdaData, ILambdaContext lambdaContext, Stream outStream) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/UserCodeLoader.cs:line 145
at Amazon.Lambda.RuntimeSupport.HandlerWrapper.<>c__DisplayClass8_0.<GetHandlerWrapper>b__0(InvocationRequest invocation) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/HandlerWrapper.cs:line 55
at Amazon.Lambda.RuntimeSupport.LambdaBootstrap.InvokeOnceAsync(CancellationToken cancellationToken) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/LambdaBootstrap.cs:line 176
2023-04-16T13:30:43.956Z d405592c-2d8b-445a-a41a-7075de51104c fail System.Net.WebException: The operation has timed out. at System.Net.HttpWebRequest.GetResponse() at System.Net.WebClient.GetWebResponse(WebRequest request) at System.Net.WebClient.OpenRead(Uri address) at System.Net.WebClient.OpenRead(String address) at SoapApiCall.Function.FunctionHandler(ILambdaContext context) in C:\Users\giacomo.carcano\.aws\SoapApiCall\src\SoapApiCall\Function.cs:line 23 at lambda_method1(Closure , Stream , ILambdaContext , Stream ) at Amazon.Lambda.RuntimeSupport.Bootstrap.UserCodeLoader.Invoke(Stream lambdaData, ILambdaContext lambdaContext, Stream outStream) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/UserCodeLoader.cs:line 145 at Amazon.Lambda.RuntimeSupport.HandlerWrapper.<>c__DisplayClass8_0.<GetHandlerWrapper>b__0(InvocationRequest invocation) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/HandlerWrapper.cs:line 55 at Amazon.Lambda.RuntimeSupport.LambdaBootstrap.InvokeOnceAsync(CancellationToken cancellationToken) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/LambdaBootstrap.cs:line 176
And this is the code that i use
using Amazon.Lambda.Core;
using System.Net;
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
namespace SoapApiCall;
public class Function
{
public string FunctionHandler(string sSQLQuery, ILambdaContext context)
{
Console.WriteLine("pippo");
sSQLQuery = "select top 10 numero,inizio,premio from dre";
string sAddress = "https://URL:52031/iservice.asmx/Query?";
//Crea il web client.
WebClient client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
//Imposta le credenziali.
client.Credentials = new System.Net.NetworkCredential("USER", "PWD");
//Effettua la chiamata.
Stream data = client.OpenRead(sAddress + "SQL=" + sSQLQuery);
client.Dispose();
StreamReader reader = new StreamReader(data, System.Text.Encoding.UTF7);
string sXML = reader.ReadToEnd();
Console.WriteLine(sXML);
return sXML;
}
}
the function is not in a Vpc infact if i try to call a simple rest service all work Good
I don't know what the problem could be.
Thanks for help
Is your SOAP endpoint on the public internet or is it private or firewalled location?