Passing payload to node guest worker & connect to same realm from gues worker.

#1

Hi,

I currently have 2 challenges that i have tried to implement but can’t really figure out how to do.

I currently have crossbar working with nodejs as a guest worker. In crossbar i can define multiple realms and connect to that. However, the guest worker has also defined a static websocket connection. I need to match these. So if somebody connects to realm1, the guestworker needs to have the settings to connect to realm1. If i connect to realm2, the guestworker needs to connect to realm2.

Visitor from website a is connecting to crossbar with realm: www.website1.com and on another website the visitor is connecting with a realm of www.website2.com. Now in the nodejs guestworker i want to be able to somehow ‘detect’ from which realm they connect and retrieve some specific contect from a database. That database part is already in place, i just need to be able to distinct this somehow in the nodejs worker. Anybody has an idea how to do this?

I tried to pass ENV variables and extend them to the guesworker however, these are not on a worker base so i can’t easily pass an extra payload to it.

Thanks in advance

0 Likes

#2

Hi,

you can have Crossbar.io pass a serialized JSON item from the node configuration to a specific guest worker on stdin:

http://crossbar.io/docs/Guest-Configuration/#configuration

Cheers,
/Tobias

···

Am 08.04.2017 um 17:32 schrieb Gerjo Greenwald:

Hi,

I currently have 2 challenges that i have tried to implement but can't
really figure out how to do.

I currently have crossbar working with nodejs as a guest worker. In
crossbar i can define multiple realms and connect to that. However, the
guest worker has also defined a static websocket connection. I need to
match these. So if somebody connects to realm1, the guestworker needs to
have the settings to connect to realm1. If i connect to realm2, the
guestworker needs to connect to realm2.

Visitor from website a is connecting to crossbar with realm:
www.website1.com and on another website the visitor is connecting with a
realm of www.website2.com. Now in the nodejs guestworker i want to be able
to somehow 'detect' from which realm they connect and retrieve some
specific contect from a database. That database part is already in place, i
just need to be able to distinct this somehow in the nodejs worker. Anybody
has an idea how to do this?

I tried to pass ENV variables and extend them to the guesworker however,
these are not on a worker base so i can't easily pass an extra payload to
it.

Thanks in advance

0 Likes

#3

Hi Tobias,

Thank you for your anwser. I tried your suggestion however, this will not solve my problem on how to distinct the connect realm in my node application and on which database to retrieve my information from. The parameters will be the same for both realms. same for the connection in the node. or should i need to think of running 2 instances or guest workers for that, i’m not really seing the practical picture on how to do this.

Any way you can point me in the right direction?

···

On Saturday, April 8, 2017 at 5:32:35 PM UTC+2, Gerjo Greenwald wrote:

Hi,

I currently have 2 challenges that i have tried to implement but can’t really figure out how to do.

I currently have crossbar working with nodejs as a guest worker. In crossbar i can define multiple realms and connect to that. However, the guest worker has also defined a static websocket connection. I need to match these. So if somebody connects to realm1, the guestworker needs to have the settings to connect to realm1. If i connect to realm2, the guestworker needs to connect to realm2.

Visitor from website a is connecting to crossbar with realm: www.website1.com and on another website the visitor is connecting with a realm of www.website2.com. Now in the nodejs guestworker i want to be able to somehow ‘detect’ from which realm they connect and retrieve some specific contect from a database. That database part is already in place, i just need to be able to distinct this somehow in the nodejs worker. Anybody has an idea how to do this?

I tried to pass ENV variables and extend them to the guesworker however, these are not on a worker base so i can’t easily pass an extra payload to it.

Thanks in advance

0 Likes

#4

Maybe you should run multiple instances of the guest worker, one for each realm?

Then you can pass in realm specific info to the worker via config or environment?

0 Likes