🐬
MySQL
When using the MySQL app driver, first you should configure your MySQL connection credentials as environment variables:
Name
Default
Possible values
Description
SOKETI_DB_MYSQL_HOST
127.0.0.1
Any string
The MySQL host.
SOKETI_DB_MYSQL_PORT
3306
Any integer
The MySQL port.
SOKETI_DB_MYSQL_USERNAME
root
Any string
The MySQL username.
SOKETI_DB_MYSQL_PASSWORD
password
Any string
The MySQL password.
SOKETI_DB_MYSQL_DATABASE
main
Any string
The MySQL database.
This database supports database connection pooling.
Once you have configured your MySQL database credentials, you should create a table with the following structure:
1
CREATE TABLE IF NOT EXISTS `apps` (
2
`id` varchar(255) NOT NULL,
3
`key` varchar(255) NOT NULL,
4
`secret` varchar(255) NOT NULL,
5
`max_connections` integer(10) NOT NULL,
6
`enable_client_messages` tinyint(1) NOT NULL,
7
`enabled` tinyint(1) NOT NULL,
8
`max_backend_events_per_sec` integer(10) NOT NULL,
9
`max_client_events_per_sec` integer(10) NOT NULL,
10
`max_read_req_per_sec` integer(10) NOT NULL,
11
`webhooks` json,
12
`max_presence_members_per_channel` tinyint(1) NULL,
13
`max_presence_member_size_in_kb` tinyint(1) NULL,
14
`max_channel_name_length` tinyint(1) NULL,
15
`max_event_channels_at_once` tinyint(1) NULL,
16
`max_event_name_length` tinyint(1) NULL,
17
`max_event_payload_in_kb` tinyint(1) NULL,
18
`max_event_batch_size` tinyint(1) NULL,
19
PRIMARY KEY (`id`)
20
);
Copied!

Environment Variables

The following environment variables are used to define the behavior of the MySQL app driver:
Name
Default
Possible values
Description
SOKETI_APP_MANAGER_MYSQL_TABLE
apps
Any string
The table to pull the app data from.
SOKETI_APP_MANAGER_MYSQL_VERSION
8.0
Any string
The MySQL version (utilized by the underlying Knex database abstraction layer).
SOKETI_APP_MANAGER_MYSQL_USE_V2
false
true, false
soketi 0.14+. If you're using MySQL 8.0+ and experience authentication issues, you may enable this option.

Limits on an app-by-app basis

To enforce app-level limits in MySQL, there are multiple fields:
1
`max_presence_members_per_channel` tinyint(1) NULL,
2
`max_presence_member_size_in_kb` tinyint(1) NULL,
3
`max_channel_name_length` tinyint(1) NULL,
4
`max_event_channels_at_once` tinyint(1) NULL,
5
`max_event_name_length` tinyint(1) NULL,
6
`max_event_payload_in_kb` tinyint(1) NULL,
7
`max_event_batch_size` tinyint(1) NULL
Copied!
Setting any of them to null or '' will ignore the setting, and use the limits associated with the server-level declared defaults.