Thread: Re: More Stations service problems

Started: 2023-02-08 16:12:07
Last activity: 2023-02-08 16:12:07
Topics: Web Services
Sebastian Heimann
2023-02-08 16:12:07
Hi!

I think I am running into the same type of problems as has been reported
previously. I find that about 1 in 30 requests returns corrupt
StationXML. Looks like there is e.g. a stray debug print statement in
the server code, printing the size of the following block as a hex value.

Here's an excerpt from one of the corrupt results (the `2000` lines are
the problem):

```
2000
<?xml version="1.0" encoding="ISO-8859-1"?>

<FDSNStationXML xmlns="http://www.fdsn.org/xml/station/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:iris="http://www.fdsn.org/xml/station/1/iris"
xsi:schemaLocation="http://www.fdsn.org/xml/station/1
http://www.fdsn.org/xml/station/fdsn-station-1.1.xsd" schemaVersion="1.1">
<Source>IRIS-DMC</Source>

...

<NumeratorCoefficient i="12">-9.78385E-7</NumeratorCoefficient>
<NumeratorCoefficient i="13">3.18969E-5</NumeratorCoefficient>
<NumeratorCoefficient i="14">1.68242E-4</NumeratorCoefficient>
<Nume
2000
ratorCoefficient i="15">-3.49811E-4</NumeratorCoefficient>
<NumeratorCoefficient i="16">-5.52227E-4</NumeratorCoefficient>
<NumeratorCoefficient i="17">7.31389E-4</NumeratorCoefficient>
<NumeratorCoefficient i="18">-0.00108921</NumeratorCoefficient>
<NumeratorCoefficient i="19">7.87631E-4</NumeratorCoefficient>

...

```

All blocks have size 0x2000 except for the last one.

Additionally the end a superfluous `0` is printed, I guess the size of
the print buffer is printed under some conditions to the response.

```
</Response>
</Channel>
</Station>
</Network>
</FDSNStationXML>
0
```

Strange that this only happens on about every 30th request. Repeating
the request with the same parameters usually returns a correct result.

Hope this helps to find the problem.

Best wishes
Sebastian




PS: here is some hotfix code for the client side to clean the possibly
corrupt StationXML after retrieval:


import io

def fix_iris_bug(data):
fin = io.BytesIO(data)
fout = io.BytesIO()
start = True
buggy = False
while True:
line = fin.readline()
if not line:
break

if start:
try:
iexpect = int(line, 16) + len(line)
buggy = True
ipos = 0
except ValueError:
pass

start = False

else:
ipos += len(line)
if buggy and ipos >= iexpect:
iexpect = int(line, 16) + len(line)
ipos = 0
else:
fout.write(line)

return fout.getvalue()



00:12:24 v.22510d55