I am using AWS websocket api gateway and I can get a connection id from the request context. The connection id is a websocket id which I need to save in our database for connection management.
What I am not sure is whether the connection id is unique? Is it possible to get a duplicate connection id when my application is running for a few years?
yes the connectionId
value provided in the context
object is unique,
from the docs
API Gateway WebSocket API mapping template reference
$context.connectionId -> A unique ID for the connection that can be used to make a callback to the client.