crotwell / seisFile

A library for reading and writing seismic file formats in java.
GNU Lesser General Public License v3.0
26 stars 20 forks source link

Some seedlink servers allow only 1 connected station? #32

Closed xspanger3770 closed 11 months ago

xspanger3770 commented 11 months ago

Hi again! I'm having a trouble when trying to select multiple stations for some seedlink servers:

  SeedlinkReader reader = new SeedlinkReader("eida.bgr.de", 18000);
  reader.select("SX", "SCHF", "", "HHZ");
  reader.select("GE", "RUE", "", "HHZ");
  reader.startData();
  while (reader.hasNext()) {
    SeedlinkPacket slp = reader.readPacket();
    System.out.println(slp.getMiniSeed().getHeader().getStationIdentifier()+", "+slp.getMiniSeed().getHeader().getChannelIdentifier()+", "+slp.getMiniSeed().getHeader().getLocationIdentifier());
   }

When I select more stations, data only arrive from the last one selected (RUE HHZ in this case). This issue happens to about 1/3 of seedlink networks that I know about.

Am I doing something wrong? Could it be that some seedlink servers simply doesn't support multi station mode?

Thank you in advance for your response. I truly appreciate your time and assistance.

crotwell commented 11 months ago

Humm, this may be a bug in my code. I was only sending the DATA command at the end, but seems like it should be between each station. I had tested with IRIS, but their server seems a bit more permissive. A workaround is to put a reader.sendCmd("DATA"); after each select, so something like:

        SeedlinkReader reader = new SeedlinkReader("eida.bgr.de", 18000);
        reader.sendHello();
        reader.select("SX", "SCHF", "", "HHZ");
        reader.sendCmd("DATA");
        reader.select("GE", "RUE", "", "HHZ");
        reader.startData();

Will try to improve this in next version.

xspanger3770 commented 11 months ago

Thanks for the response! Seems like the workaround indeed works only for the seedlinks that had initially experienced the 1 station issue, and for the ones that worked before I get Command DATA did not return OK.

Will probably use another workaround where it first tries to send DATA command after each station and if that fails it will only call select after each station.

Thanks! I really couldn't figure that out before

crotwell commented 11 months ago

Can give an example of one that is still not working? It would be helpful for my testing.

xspanger3770 commented 11 months ago

Sure! I did some additional testing and was able to reproduce the error like this:

SeedlinkReader reader = new SeedlinkReader("rtserve.resif.fr", 18000);
reader.sendHello();
reader.select("FR", "AGO", "00", "HHZ");
reader.sendCmd("DATA");
reader.select("FR", "CHLF", "00", "HHZ");
reader.sendCmd("DATA");
reader.select("FR", "PLDF", "00", "HHZ");
reader.sendCmd("DATA");
reader.startData();

But it seems like the problem might be the last DATA command after the last select command as no error occurs without it

xspanger3770 commented 11 months ago

The problem is indeed the last DATA command. After putting it only between the select commands, everything works perfectly now for all seedlinks.

crotwell commented 11 months ago

Yes, the startData() send a "DATA" command, which results in a duplicate.

xspanger3770 commented 11 months ago

Thanks for the help! Your library is otherwise really good and simple to use!

crotwell commented 11 months ago

I've updated SeedLinkReader to make this easier in 3a15780536ac9fd85c0d77c2a293191b3b5ab7f3

See https://github.com/crotwell/seisFile/blob/main/src/client/java/edu/sc/seis/seisFile/example/SeedLink.java for an example that uses new style that will be in next version.

xspanger3770 commented 11 months ago

Great, looking forward for the next version!