Centrifugo - Running Environment
Prerequisite Reading
Relevant Config Values
Config/config.json
The majority of the setup should already be done based on the parent Getting Started page, but ensure that the config.centrifugo.publicUrl
and config.centrifugo.apiUrl
are pointing towards the same host/port, and that the port is free.
centrifugo-config.json
In the main directory, there is a centrifugo-config.json
.
Ensure that in client.allowed_origins
that the value in config.open.publicUrl
is the array value.
Ensure that in client.proxy.connect.endpoint
and channel.proxy.subscribe.endpoint
that the value in config.api.publicUrl
is there. It should consist of api endpoints /api/centrifugo/connect
and /api/centrifugo/subscribe
in there respectively.
The value for channel.namespaces[...].subscribe_proxy_enabled
should also be true
.
For example, if my config.open.publicUrl
was http://localhost:7000
, and my config.api.publicUrl
was http://localhost:8080
, then my centrifugo-config.json
would look like this:
{
...,
"client": {
...,
"allowed_origins": [..., "http://localhost:7000", ...],
"proxy": {
"connect": {
"endpoint": "http://127.0.0.1:8080/api/centrifugo/connect",
...
}
}
},
...,
"channel": {
"proxy": {
"subscribe": {
"endpoint": "http://127.0.0.1:8080/api/centrifugo/subscribe",
...
}
},
"namespaces": [
{
"name": "matchup",
"subscribe_proxy_enabled": true,
...
},
...
],
...
}
Running the Environment
To reiterate from the parent Getting Started page, run the following command to start the centrifugo server in development mode:
npm run centrifugo
In the console, there should be no errors when running.
Local Centrifugo
This is only for if the above doesn’t work, which can happen in Windows/WSL.
Download a v6.x.x binary from latest releases, and place it in the parent directory.
Afterwards, go to scripts.centrifugo:local
in package.json
located in the parent directory, and ensure it has the same port listed in config.centrifugo.publicUrl
and config.centrifugo.apiUrl
.
Once done, it should run using the following command
npm run centrifugo:local
In the console, there should be no errors when running.