java - How I can change default timeout for web services call on Google app engine? -


my google app engine application use web service, web service pretty slow respond , application crashes :

java.net.sockettimeoutexception: timeout while fetching url: http://...

to call web service, use classes generated wsimport (java tool parse existing wsdl file , generate required files).

i need change default deadline (5 seconds) either call or globally app url fetches.

app engine docs :

you can set deadline request, amount of time service wait response. default, deadline fetch 5 seconds. maximum deadline 60 seconds http requests , 10 minutes task queue , cron job requests. when using urlconnection interface, service uses connection timeout (setconnecttimeout()) plus read timeout (setreadtimeout()) deadline.

source : https://developers.google.com/appengine/docs/java/urlfetch/#java_making_requests

i tried add lines (in strong below) in code change deadline did'nt work :

url urlconnection = new url(url);

urlconnection connection = urlconnection.openconnection();

connection.setconnecttimeout(180000); // 3 minutes

connection.setreadtimeout(180000); // 3 minutes

sws webservice = new sws(urlconnection, new qname("http://...", "sws"));

note : sws main class generated wsimport wsdl

posted here min ago, there no accepted answer: can globally set timeout of http connections?

for app engine jax-ws have set request context (tested today sdk 1.9.15). normal machines cannot go higher 60s , have switch bigger machines (bx) better use task queue.

for local testing use bindingproviderproperties.connect_timeout , bindingproviderproperties.request_timeout, not on app engine jre white list , code inspection might warn that. equivalent strings can used though:

com.sun.xml.internal.ws.connect.timeout com.sun.xml.internal.ws.connect.timeout 

for deployment app engine:

com.sun.xml.ws.connect.timeout com.sun.xml.ws.request.timeout 

a full example how apply auto-generated code jax-ws 2.x, values have provided in milliseconds:

@webendpoint(name = "your.randomserviceport") public yourserviceinterface getyourrandomserviceport() {     yourrandomserviceinterface port = super.getport(yourrandomservice_qname_port, yourrandomserviceinterface.class);     map<string, object> requestcontext = ((bindingprovider)port).getrequestcontext();     requestcontext.put("com.sun.xml.ws.connect.timeout", 10000);     requestcontext.put("com.sun.xml.ws.request.timeout", 10000);     return port; } 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -