1.1.3 • Published 5 years ago
swizi-chat-proxy v1.1.3
Swizi chat Proxy Helper
This library is a helper to create a Chat Proxy to allow load-balancing facilities on Swizi Chat Server.
Summary
Installation
npm i swizi-chat-proxy
or
yarn add swizi-chat-proxy
Load balancing considerations
Swizi Chat Server uses session affinity (or sticky session) to manage load balancing. This method need to embed a http session cookie in socket.io exchange. Unfortunately, if http session are not available from js in a browser application, so cookie must be embedded in the browser and the chat server must on the same address than your application server. To fix this issue, you must use a ChatProxy on your server (the one which exposes your application). This proxy will be call by your ChatClient and this proxy will deal with ChatServer. ChatProxy is included in the library, and below is a example to use it :
import express from 'express'
import ChatProxy from 'ChatProxy'
let app = express()
let server = require('http').Server(app)
ChatProxy(server, 'https://ms-chat.swizi.io')
// Do what you have to do with your server.
server.listen(3000, ()=>{
console.log('Server started !')
})