CabloyJS v3.2.0 introduces Socket IO
and implements a unified mechanism for online push
and offline push
Demo
1. IM
The user sends a message to the system, and the system pushes a reply to the user through websocket online channel
2. Progress Bar
The system pushes task progress to the frontend in real time through websocket online channel
Configuration
To upgrade to this version, please update the following project configuration:
1. Add redis connection information
Please modify the configuration of test environment
, development environment
and production environment
in turn. Take development environment
as an example here:
{project}/src/backend/config/config.local.js
// redis
...
const __redisConnectionDefaultIO = Object.assign({}, __redisConnectionDefault, {
keyPrefix: `io_${appInfo.name}:`,
});
config.redisConnection = {
...
io: __redisConnectionDefaultIO,
};
config.redis = {
clients: {
redlock: config.redisConnection.default,
...
io: config.redisConnection.io,
},
};
2. Nginx Configuration
Add a rule for /socket.io/
in nginx configuration
{project}/docker-compose/config/nginx/conf.d/nginx.conf
...
location /socket.io/ {
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://$node_ip:$node_port$request_uri;
proxy_redirect off;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
}
Comments: