


However, we can’t run one property space on more instances. OngoingĮnhanced load balancing: at the present time, more properties space run in one instance and when the number of properties increases, we add more instances. If it’s expired and not renew yet, client will be disconnected with reason unauthorized - the client will then begin the process of reauthirising with the authorisation server and reconnect to Direct socket service.Īn another option is create a queue job to check JWTs and disconnect a client asap if it doesn’t renew token yet. When server want to broadcast to clients in channel then it will check JWTs not expired. What’s happen if the JWT expires and cannot refreshĪfter authenticated, client JWT will be kept in socket connection. Like HTTPS, WebSocket has a secure protocol wss:// that is encrypted, thus protecting against man-in-the-middle attacks.įortunaty, when we initialize a connection it is https, Socket.io will then establish a WebSocket using wss without any additional line of code. Request then check if client support then it will establish a WebSocket. It initializes the connection with a http request. Socket.io uses WebSocket as a transport when possible. If timeout reached and Server 1 doesn’t receive FA2 yet to dequeue then it return error to other service.Server 1 know that it should handle this request so it read data from FA2 and return in http response.Server 1 and 3 subscribe event FA2 via check http request in FA2 is in its queue.After broadcast success, Server 2 publish an event FA2 to Redis to report all success.Server 2 holding space property A so it get data from FA1 and broadcast to clients that join this space.Server 2 and 3 subscribe event FA1 and check if it holding space property A.Server 1 start a timeout and put http request to its queue then it publish an event FA1 via Redis to found server holding space property A.

When client is authenticated to access in space, it could listen all notifications in channel but we should not contain too much sensitive data in notification.Ĭlient can ask server to leave channel by send event leave_room and wait until receive leaved_room We can add an authentication step when client ask to join channel but I feel it is unnecessary and complicated. Client need to ask server before join to channel by event join_room and wait until receive joined_room If channel isn’t exist then server will create new one and add client in. When connected to a space, client can join to any channel in space to listen notification in channel. Every time client receive new token, it must emit event authenticate with new JWT to server double check.If it’s expired then send disconnect with reason unauthorized Every time server sends message to client, server will verify client JWT hasn’t expired yet.Otherwise, the server sends authorized event to the client and then start exchanging messages.If an invalid JWT or a space isn’t in the client JWT or a timeout occurs then the server will disconnect client with reason unauthorized.If client send event authenticate with JWT before timeout then server will verify it with space that client want to connect.After client connected, server will set a timeout and wait client send event authenticate.Client connect to a space (property) of server.With this requirement, Pub/Sub paradigm is suitable Other service can broadcast to all clients in topic, data to broadcast is customizable.Server can actively disconnect from client for security reason.Client can subscribe more channels at same time or leave channel.Other services want to send notification to clients then send via this central point with easy private API (e.g. A central point to manage incoming clients.Space can have many channels: notifications, tasks, alerts and more and client can choose a channel to subscribe. Each property is a space, client must be authenticated to access a space (using the Altitude JWT).
ANDROID REALTIME NOTIFICATION SOCKET IO ANDROID
