push_stream_ping_message_text
Sets the custom text for ping messages sent to clients in the NGINX push stream module.
Description
The push_stream_ping_message_text directive specifies the custom text to be sent as a ping message to connected subscribers in the push stream module. This is particularly useful for maintaining connections and keeping the client-side application aware that the server is still reachable and functioning correctly.
The ping messages are sent at regular intervals to verify the connection status and prevent timeout issues that may lead to lost connections due to inactivity. By default, this message can be a simple string, and the actual frequency of ping messages is controlled by another directive, which configures timing.
Using this directive in your configuration allows for greater customization of how the server communicates with clients, which may enhance users' experience by providing regular updates or heartbeats. It's critical to ensure that the message does not exceed size constraints imposed by other related configuration settings to avoid potential transmission errors.
Config Example
http {
push_stream_ping_message_text "Heartbeat";
push_stream_shared_memory_size 32M;
server {
location /pub {
push_stream_publisher admin;
push_stream_channels_path $arg_id;
}
location ~ /sub/(.*) {
push_stream_subscriber;
push_stream_channels_path $1;
}
}
}Ensure that the ping message text does not exceed 255 bytes to prevent client connection issues.
Overusing ping messages can lead to increased network traffic; balance is essential.