I'm trying to fetch the content of a webpage from AWS Lambda but it fails silently, CloudWatch logs just contain the following lines (timeout is set to 10secs so that's why duration is 10000ms):
START RequestId: f101849f-1219-411b-8875-8944a76de937 Version: $LATEST
END RequestId: f101849f-1219-411b-8875-8944a76de937
REPORT RequestId: f101849f-1219-411b-8875-8944a76de937 Duration: 10008.39 ms
The code I'm running just takes the URL and reads the content. It works fine from local environment but it doesn't when testing on AWS Lambda:
public class TestHandler implements RequestHandler<Object, String>{
@Override
public String handleRequest(Object o, Context context) {
try {
Connection con = HttpConnection.connect(new URL("https://www.google.com"));
con.timeout(40000);
return con.get().getAllElements().toString();
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
Any AWS restriction that I'm not aware of when dealing with requests?