Manfred wrote:
> marcella...@gmail.com wrote:
> > Wat is de best way to recover from a 502 error? Im using nusoap in PHP.
>
> Assuming you are using HTTP/1.1
> 1. Read the response headers
> 2. Read the response
> a. for xml - use chunked size
> b. for html - use Content-Length
> 3. Process response
> a. Status 200 - normal processing
> b. Status 502 - #_502 < 6 - retry request
> c. Status 502 - #_502 = 6 - error msg
> d. other - error msg with headers + response
>
> Note: In case of a 502 the response from the server is
> _not_ a xml (SOAP), but a html (not wellformed).
>
> Hope this helps,
>
> Manfred
That means to keep trying until the website is recovered.
I am using perl to get access to the webservice:
my $service =
SOAP::Lite->service('http://gr.fadshop.net/GoogleSearch.wsdl');
my $result = $service->doGoogleSearch($key, $query, $page*10, 10,
"false", "", "false", "", "UTF-8", "UTF-8");
I tried to query 3 times to show the 30 entries. The program worked
pretty well when there's no 502 error. Now it kept getting errors, and
when I check the log, I found it got the 502 error in the second loop.
So I decrease the loop number into 1, only query 1 time to show 10
entries. Now the program works pretty stable.
I assume the server block too frequent query from one client.
So I also copy the wsdl file into my server, to eliminate the need to
visit Google server one more time.
I hope this helps.
Ben.
No. To make it more clearly, in case of a 502 you need to
1. Read the response headers (done, otherwise you wouldn't know about)
2.b. Read the response, using Content-Length
3.b. Process response, retry
The crucial point is 2.b.: if you don't read the response, the 502 is
_not_
cleared until some timeout occurs on the API server. In other words, if
you retry without reading the response, you will encounter the 502
for each request until its finally cleared by a timeout.
The other way to clear the 502 is to disconnect from the service and
then connect again for each request. This is essentially using HTTP/1.0
instead of HTTP/1.1, and may take much longer.
Hope this helps.
Manfred
ALl the same I wrote a test program and get the infamous 502 error and
then my for loop does not recover. i.e I say setStartresult to say 700
, but yet the returned result has a totally random start index , and it
gets "stuck" like that.
I saw your post where you say I need to read the response.
> > > Assuming you are using HTTP/1.1
> > > 1. Read the response headers
> > > 2. Read the response
> > > a. for xml - use chunked size
> > > b. for html - use Content-Length
> > > 3. Process response
> > > a. Status 200 - normal processing
> > > b. Status 502 - #_502 < 6 - retry request
> > > c. Status 502 - #_502 = 6 - error msg
> > > d. other - error msg with headers + response
> > >
> > > Note: In case of a 502 the response from the server is
> > > _not_ a xml (SOAP), but a html (not wellformed).
> > >
Can you tell me how to do this. The printstacktrace gives me some info
, but I dont know how to "Use HTTP/1.1 " and so steps 2 and 3 you
suggested below.
Can you point me in the direction of the correct soap/java api that I
need to use to recover from this.
Here is what I see
com.google.soap.search.GoogleSearchFault: [SOAPException:
faultCode=SOAP-ENV:Protocol; msg=Unsupported response content type
"text/html", must be: "text/xml". Response was:
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>502 Server Error</title>
<style><!--
body {font-family: arial,sans-serif}
div.nav {margin-top: 1ex}
div.nav A {font-size: 10pt; font-family: arial,sans-serif}
span.nav {font-size: 10pt; font-family: arial,sans-serif; font-weight:
bold}
div.nav A,span.big {font-size: 12pt; color: #0000cc}
div.nav A {font-size: 10pt; color: black}
A.l:link {color: #6f6f6f}
A.u:link {color: green}
//--></style>
<script><!--
var rc=502;
//-->
</script>
</head>
<body text=#000000 bgcolor=#ffffff>
<table border=0 cellpadding=2 cellspacing=0 width=100%><tr><td
rowspan=3 width=1% nowrap>
<b><font face=times color=#0039b6 size=10>G</font><font face=times
color=#c41200 size=10>o</font><font face=times color=#f3c518
size=10>o</font><font face=times color=#0039b6 size=10>g</font><font
face=times color=#30a72f size=10>l</font><font face=times color=#c41200
size=10>e</font> </b>
<td> </td></tr>
<tr><td bgcolor=#3366cc><font face=arial,sans-serif
color=#ffffff><b>Error</b></td></tr>
<tr><td> </td></tr></table>
<blockquote>
<H1>Server Error</H1>
The server encountered a temporary error and could not complete your
request.<p>Please try again in 30 seconds.
<p>
</blockquote>
<table width=100% cellpadding=0 cellspacing=0><tr><td
bgcolor=#3366cc><img alt="" width=1 height=4></td></tr></table>
</body></html>
]
at
com.google.soap.search.GoogleSearch.doSearch(GoogleSearch.java:197)
at
hjgoogleweb.GetResultsAndSaveToFile.searchit(GetResultsAndSaveToFile.java:51)
at
hjgoogleweb.GetResultsAndSaveToFile.main(GetResultsAndSaveToFile.java:68)
Your help will be greatly appreciated.
Thanks
Hari Jayaram
Brandeis University
I would propose to take this question to a perl forum. I cannot
currently test with perl but I'm willing to contribute if you would
post the address of the thread here.
Best regards,
Manfred
I am using java and am very new to soap. I did try looking for a good
perl group.but I am sure you can point me in the right direction..
With reference to your suggestion for recovery from 502 you said..
> > > > > 2. Read the response
> > > > > a. for xml - use chunked size
> > > > > b. for html - use Content-Length
Right now the only output I get from the web api is generated by a
call..
com.google.soap.search.GoogleSearch.doSearch()
This Is a formatted text with serach result OR error messages..
Does the fact that I have to "read the response" imply that I have to
construct my soap request form scratch and not use the simple
GoogleSearch Class with its dosearch method?
Sorry for requesting to be spoon-fed but since I am a beginner I
request you to just point me in the right direction.
Thanks
Hari J
Brandeis University
> > need to use to recover from this.I would propose to take this question to a perl forum. I cannot
> With reference to your suggestion for recovery from 502 you said..
>
> > > > > > 2. Read the response
> > > > > > a. for xml - use chunked size
> > > > > > b. for html - use Content-Length
>
> Right now the only output I get from the web api is generated by a
> call..
>
> com.google.soap.search.GoogleSearch.doSearch()
>
>
> This Is a formatted text with serach result OR error messages..
>
> Does the fact that I have to "read the response" imply that I have to
> construct my soap request form scratch and not use the simple
> GoogleSearch Class with its dosearch method?
If soap-lite does not support such a low level interface, it should
be possible to do it by either modifying the soap-lite locally or by
using java directly, we'll see ...
Manfred
Many thanks for your quick response and the link. Really appreciated.
I'll go through the link (or posted messages) and I hope I'll find
the answers.
I've also tried to access the Google's WSDL (i.e.
http://api.google.com/GoogleSearch.wsdl) and got the following message:
"The server encountered a temporary error and could not complete your
request. Please try again in 30 seconds."
Many thanks and have a good day.
Rgds
DKL
Manfred