c# - Azure Long-running external web service calls -
i've written windows service in c# interfaces third party via external web service calls (soap). of calls respond , slowly
(for example, quick = retrieving list of currencies; slow = retrieving historical value of currencies per product on many years)
the external service works fine when run on local machine - quick calls runs 20 seconds; slow calls runs 30 minutes. can't speed of 3rd party service , don't mind time takes return answer..
my problem when deploy service azure virtual machine: quick call works locally; slow ones never returns anything. have tried exception handling, logging files, logging eventlog.
there no clear indication of goes wrong - seems whatever reason - long running web service calls, never return azure.
i've read somewhere there sort of connection-recycling happening every 4 minutes, suspect somehow causing external web service response land somewhere in void load balancer or whatever not knowing longer whom requested content.
i start creating request relevant soap envelope, this:
httpwebrequest trequest = (httpwebrequest)webrequest.create(endpoint);
then set stuff, this:
trequest.clientcertificates.add(clientcertificate); trequest.preauthenticate = true; trequest.keepalive = true; trequest.credentials = credentialcache.defaultcredentials; trequest.contentlength = bytearray.length; trequest.contenttype = @"text/xml; charset=utf-8"; trequest.headers.add("soapaction", @"http://schemas.xmlsoap.org/soap/envelope/"); trequest.method = "post"; trequest.timeout = 3600000; servicepointmanager.servercertificatevalidationcallback = delegate { return true; }; //the ssl certificate bad stream requeststream = trequest.getrequeststream(); requeststream.write(bytearray, 0, bytearray.length); requeststream.close(); requeststream.dispose(); //works fine point. webresponse webresponse = trequest.getresponse(); //the slow calls never make past this. fast 1
anyone else experienced similar , suggestions how solve please?
many thanks
when deploy azure (cloud service, virtual machine) there azure load balancer, sits between vms , internet.
in order keep resources equally available cloud users, azure load balancer kill idle connections. idle azure lb - default 4 minutes of no communication sent on established channel. if call web service , there absolutely no response on pip 4 minutes - connection terminated.
you can configure timeout, argue need keeping connection open long. yes, can nothing it, besides looking service has better design (i.e. either returns responses faster, or implements asynchronous calls first call service give task id, using can poll periodically result)
here article on how configure azure load balancer timeout. aware, maximum timeout azure lb 30 minutes.
Comments
Post a Comment