crotwell / seisplotjs

Javascript modules for parsing, manipulating and plotting seismic data.
http://crotwell.github.io/seisplotjs/
MIT License
61 stars 7 forks source link

Connection to own SeedLink Server #4

Closed nchazarra closed 1 year ago

nchazarra commented 1 year ago

Hi,

I'm trying to plot my own seismograms on my local machine. I'm running ringerver on my network, but can't find the way to make a connection to my ringserver and plot the seismograms. Is it possible to plot waveforms from a SeedLink server? If so, how?

I tried to use the examples, but maybe I'm missing something while writing my own web.

Thanks.

crotwell commented 1 year ago

Yes it is possible. Without knowing more about the error you saw and your configuration it is hard to help. Check the broswers console and see if anything useful is printed.

The things to check first are that your ringserver is set up with a ListenPort and you don't have a firewall blocking connections. Test by pointing your browser to get the id, for example:

http://eeyore.seis.sc.edu:6382/id

Seisplotjs running in a browser can only do websockets, not regular sockets, so if you can't do the http:// then the ws:// won't work.

Also you need cors header set up correctly.I have in my ringserver config

ListenPort 6382
WebRoot /data/scsn/www/ringserver-web
HTTPHeader "Access-Control-Allow-Origin: *"
HTTPHeader "Cache-Control: no-cache"

Lastly, a page loaded with https is not allowed to connect to an insecure web socket, so if you are loading via https, you also need to connect to the ringserver with wss

Good luck

nchazarra commented 1 year ago

Hi,

First, thanks for your quick answer. My SeedLink server was working (I tested it with the address you told me and I got the correct answer "ringserver/2020.075 Organization: Rojales"), but not my code. I was trying to adapt the example 7 of the documentation for connecting to my SeedLink server, but my javascript knowledge is quite basic and obviuosly that is the problem. I will try to ask a friend to help me with the code.

Thanks!!

nchazarra commented 1 year ago

Hi again,

I tried to adapt one of the examples using this configuration:

if (wsProtocol == 'wss:' && host == IRIS_HOST) { console.log("IRIS currently does not support connections from https pages, I will attempt anyway, but you may wish to try from a http page instead."); }

var my_server = "myserver"; var host = my_server; var port = 18000; var seedlinkUrl = wsProtocol+"//"+host+(port==18000?'':'80'); console.log("URL: "+seedlinkUrl);

var config = [ 'STATION ROJ01 ES', 'SELECT 00EHE', ];

//wp.createPlotsBySelector('div.myseisplot'); console.log("before select");

But I seem not able to connect. These are the errors shown in the console:

image

crotwell commented 1 year ago

The URL looks invalid to me. It should be the same as the URL you used to test the ringserver id, but with http replaced with ws, so

http://eeyore.seis.sc.edu:6382/id

becomes

ws://eeyore.seis.sc.edu:6382

You need to give the actual DNS name of your machine instead of 'myserver':

var my_server = "myserver";
nchazarra commented 1 year ago

Hi again,

Sorry, I used for example my_server, but I had on the code the correct host url: "homeassistant.local" image

But still have the same problem: image

I can connect with the browser to this server, and also use programs as swarm or libraries like obspy: image

crotwell commented 1 year ago

Try

ws://homeassistant.local:18000/seedlink
nchazarra commented 1 year ago

Hi,

Thanks again. That was the solution, adding /seedlink in the end.

Greetings and thanks for your help.