When many devices communicate with the server at the same time, the server crashes. To avoid this situation WSO2 IoT Server implemented a task to manage the number of devices communicating with the server at a given time. The task sends the notifications to the devices in batches. This way at a given time only a defined number of devices will communicate with the server.
<IOTS_HOME>/conf/cdm-config.xmlfile and make sure the
SchedulerTaskEnabledthat is under
PushNotificationConfigurationis enabled. This configuration is enabled by default.
In a clustered environment make sure to enable this task only in the manager node and not the worker nodes. Else, the server crashes when the worker nodes start pushing notifications along with the manager node.
Define how many devices or the device batch size a notification needs to be sent at a given time.
By default, a notification is sent to 200 devices at a given time. If you have less than 200 devices registered with WSO2 IoT Server, the notification will be sent to all those devices.
Define after how many milliseconds the notifications needs to be sent to the next batch of devices.
By default, the next batch of devices will get the notification after 60,000 milliseconds, which is in a minute.
The server will not send notifications to the devices soon as it starts. Therefore, define when the push notification schedule task needs to start. The value needs to be defined in milliseconds.
By default, the task starts 60,000 milliseconds or one minute after the server starts.
Enable the push notification scheduler task. If it is is not enabled, WSO2 IoT Server will send the push notifications to all the registered devices in one go. This might result in the server crashing as explained above.
The default push notifications that are supported and implemented in WSO2 IoT Server.
Configure the device type to run the push notification scheduler task.
Navigate to the
<IOTS_HOME>/repository/deployment/server/devicetypedirectory, open the
<DEVICE_TYPE>.xmlfile, and configure the field given below:
The default configuration in the
android.xmlfile is shown below:
The task for the FCM push notification method is disabled for the Android device type by default. Therefore, all the Android devices registered with WSO2 IoT Server will receive the push notifications at once and the devices will communicate with the server at the same time. If you want to change this default behavior, enable the scheduler task for the device type.
NOTE: In WSO2 IoT Server, the Android devices are configured to send notifications via the local polling notification method by default.