dm3 icon indicating copy to clipboard operation
dm3 copied to clipboard

BUG delete session ID on disconnect

Open AlexNi245 opened this issue 10 months ago • 0 comments

To decide whether to send a Notification, the delivery service has to know if the receiver of a message is currently connected and able to receive the message.

At the moment the session.socketId will be used for that. If it's not undefined the DS assumes the receiver is online and submits the notification. https://github.com/dm3-org/dm3/blob/4d0bcec5cfd2bc12f8f1d636612c29c64b145249/packages/lib/delivery/src/Messages.ts#L204

The problem here is that the socketId will never be deleted on disconnect. That leads to the behavior that the DS sends the Notification to a socket that is no longer connected instead of sending a Notification.

A potential solution would be to eliminate the sessionId of the client when the connection is lost, so that it becomes undefined as soon as the client disconnects. The event listener is already present, but it presently only logs and provides information on disconnection. https://github.com/dm3-org/dm3/blob/4d0bcec5cfd2bc12f8f1d636612c29c64b145249/packages/backend/src/messaging.ts#L22

AlexNi245 avatar Apr 04 '24 12:04 AlexNi245