http - Making calls to web-services on AWS Lambda using Java -


i trying call external web-service java aws lambda function. can't org.apache.http client work. have code:

public static string get(string get) throws clientprotocolexception, ioexception{     requestconfig defaultrequestconfig = requestconfig.custom().setexpectcontinueenabled(true).build();     httpget httpgetrequest = new httpget(get);     requestconfig requestconfig = requestconfig.copy(defaultrequestconfig).setsockettimeout(5000).setconnecttimeout(5000).setconnectionrequesttimeout(5000).build();     httpgetrequest.setconfig(requestconfig);      closeablehttpclient httpclient = httpclientbuilder.create().build();     httpresponse httpresponse = httpclient.execute(httpgetrequest); <<<<<     httpentity entity = httpresponse.getentity();     stringbuffer = new stringbuffer();     if (entity != null) {         inputstream inputstream = entity.getcontent();         bufferedreader in = new bufferedreader(new inputstreamreader(new bufferedinputstream(inputstream)));         string read;         while ((read = in.readline()) != null){             all.append(read);             all.append("\n");         }         httpclient.close();     }     return all.tostring(); } 

once deployed hangs on line httpresponse httpresponse = httpclient.execute(httpgetrequest); <<<<< above.

i can prove have connectivity lambda function internet setting socket connection e.g. socket s = new socket(inetaddress.getbyname("bbc.co.uk"), 80); , can retrieve data way.

so question either wrong first code fragment works locally not when deployed? or there preferred way call web-services aws lambda functions in java (i have had search can't find best practice) ? prefer not have hand craft http requests using sockets if can it.

please try use rest template make call.