MqttX.Session.ETSStore (MqttX v0.7.0)

View Source

ETS-based in-memory session store.

This is the default session store implementation. Sessions are stored in an ETS table and persist for the lifetime of the BEAM VM.

Options

  • :table - Name of the ETS table (default: :mqttx_sessions)

Usage

{:ok, client} = MqttX.Client.connect(
  host: "localhost",
  client_id: "my_client",
  clean_session: false,
  session_store: MqttX.Session.ETSStore
)

# Or with custom table name
{:ok, client} = MqttX.Client.connect(
  host: "localhost",
  client_id: "my_client",
  clean_session: false,
  session_store: {MqttX.Session.ETSStore, table: :my_sessions}
)

Limitations

  • Sessions are lost when the BEAM VM restarts
  • Not suitable for distributed deployments (sessions are node-local)

For persistent storage across restarts, implement a custom store using the MqttX.Session.Store behaviour with your preferred database.