labstreaminglayer / LSL4Unity

A integration approach of the LabStreamingLayer Framework for Unity3D
Other
83 stars 38 forks source link

Cannot get streams outside the local network #26

Closed avourvopoulos closed 2 years ago

avourvopoulos commented 5 years ago

Hi,

Although I receive all streams through the local network (i can see them in LabRecorder), I cannot receive in Unity. Only from localhost. Searching a bit further, I found that LSL can be customized through an lsl_api.cfg (source: https://github.com/sccn/labstreaminglayer/wiki/NetworkConnectivity.wiki#customizing-network-features-of-lsl) placed in the root or specific folders.

I tried that also (see file: lsl_api.txt) without success.

Is this plugin able to receive from network streams or load the aforementioned .cfg file? Is anyone receiving successfully from the local network?

PS. Great work btw.

Thanks.

dholdaway commented 2 years ago

@thanosvr did you ever resolve this? i am also struggling with the same issue

agricolab commented 2 years ago

Plugins are usually wrapping the underlying liblsl library, and that one is able to send and receive network streams.

The aforementioned .cfg file is loaded during startup of the plugin (please note that file you submitted has an .txt extension and should end in .cfg'.

@dholdaway , did you try any of the steps as described in https://labstreaminglayer.readthedocs.io/info/network-connectivity.html ?

jfrey-xx commented 2 years ago

In Unity, did you leave enough time in the timeout parameter of the resolve stream function? (It happened to me that I was manually resolving streams and could not see anything besides localhost because of a timeout that I set to 0 to make it non blocking)

dholdaway commented 2 years ago

Ok,

When I use the editor drop down I can see my stream, when I have the stream running on the same computer it is working.

Where do I place the .cfg ? Location related to the lsl4unity folder.

I have also disabled firewall on local network.

I can see the ports open and sending and receiving the streams.

jfrey-xx commented 2 years ago

In the editor do you see only local streams as well, or do you see all streams? If the latter, that is another sign that everything is fine with network configuration and that you don't need to play furthermore with the cfg file. This discrepancy between editor and running program was actually what made me look at the timeout parameter in the first place. Can you share some snippets of the code you are using?

Note: by default configuration should be shared between all instances of LSL, hence if on the same computer LabRecorder show all streams, the config is not likely the culprit, or at least you should make sure LSL4Unity uses the same (the lib will also look for cfg files in local folder I believe).

agricolab commented 2 years ago

Where do I place the .cfg ? Location related to the lsl4unity folder.

Probably safest if you use a global or user-specific lsl_api.cfg. https://labstreaminglayer.readthedocs.io/info/lslapicfg.html#configuration-file-locations

How could the lsl_api.cfg be involved? For example: a) you load accidently a lsl_api.cfg with a different session id, e.g. the streaming PC uses default, but the receiving PC whatever b) Add the IP adress of the streaming PC to knownpeers can aid detection in the network.

dholdaway commented 2 years ago

I have just set a .cfg file in the C:\etc\lsl_api as per instructions

and I have set the knownpeers to that of my ubuntu box which is sending the stream.

image

I can see the streams in the utility, and the console tries to resolve them.

image

I am just trying with the examples

jfrey-xx commented 2 years ago

I recalled that I actually had a different fix for LSL4Unity: if you look at the code, with current implementation in AInlet the resolver is called only once upon start. But when distant streams are involved, it is not likely that the resolver will have time to fetch them during this short window. Hence I changed AInlet.cs to keep calling the resolver at each update until it finds the targeted stream. See https://github.com/jelenaLis/LSL4Unity/commit/4576012bdab2fd5d7187fd8f46157dcfbbb60924 for a change to FloatInlet, and https://github.com/jelenaLis/LSL4Unity/commit/4698399f7c2e640051c9a02c843936d9b627bddd for the other types of inlets (and a more readable commit). It's a hack but it worked enough for running a full experiment involving different computers. Yon can copy and paste the modification to you own AInlet.cs, or grab the whole fork for a quick try. If it works I'll try to submit a PR :)

dholdaway commented 2 years ago

@jfrey-xx EXCELLENT! yeah, the steam is now appearing in the console! thanks for this.

agricolab commented 2 years ago

Would you then agree that we can close the issue?

dholdaway commented 2 years ago

I would agree