sccn / labstreaminglayer

LabStreamingLayer super repository comprising submodules for LSL and associated apps.
Other
522 stars 157 forks source link

Best way to send data from a device to the web #98

Open AntonelloBS opened 2 years ago

AntonelloBS commented 2 years ago

Hello, for a project of mine I would like to send data acquired from a device with LSL to the Web. Right now I am pulling data from the device with a timeout of 0 and sending them to the web via HTTP post request (I am using HTTP connection pooling instead of classic HTTP). It is somehow a slow process, I can't get a good timing, so I have 2 questions:

  1. Do you know a better way to send data to the web at a high rate?
  2. Is there a possibility to make the outlet and inlet communication happening on localhost and then using the internet connection just to send the data to the web? I red that I can use the configuration file to do something like that, but I don't know how to.

Thanks

cboulay commented 2 years ago

LSL can communicate between processes on localhost, within a subnet, and even across the internet (the latter is maybe what you read w.r.t. configuration file changes). I'm not sure if this is what you meant by "web".

As for getting it in the browser -- whether that's on localhost or on another computer -- as far as I know there is currently no good way to pull data from an LSL stream into a javascript process. websockets aren't implemented. So you would probably need a webserver that reads in data from LSL then serves it to browsers.

AntonelloBS commented 2 years ago

OK, can I force the inlet and outlet to communicate only on localhost? Do I have to use the knowPeers or the ResolveScope?

cboulay commented 2 years ago

I've never used this feature so I don't know off-hand. I think KnownPeers is more of a fallback rather than a limiter. In addition to ResolveScope, you might want to look into LinkAddresses. Sorry I can't be more helpful at the moment.

AntonelloBS commented 2 years ago

What is link Adresses used for?

cboulay commented 2 years ago

The most reliable way to understand what the different lsl_api.cfg entries do is to look at the code. In this case: https://github.com/sccn/liblsl/blob/master/src/api_config.h#L87-L103