Protocol extensions - traffic pipeline for user defined TCP client and server behaviors
The following figure illustrates the sample protocol extension - traffic pipeline for user defined TCP client and server behaviors
Add a custom protocol by using protocol extensions
The command line interface (CLI) commands for custom protocol use the keyword “user” to signify the user defined nature of the underlying configuration entities. With the help of extension code, you can add a new user protocol to the system and add user virtual servers for user-defined protocols. The user virtual servers are in turn configurable by setting parameters. Configured values for virtual server parameters are available in the extension code.
The following example illustrates the user flow for adding support for a new protocol. The example adds MQTT protocol support to the system. MQTT is a machine-to-machine “Internet of Things” connectivity protocol. It is a lightweight publish/subscribe messaging transport. Useful for connections with remote locations, this protocol uses client and broker tools to publish messages to subscribers.
1. Import the MQTT protocol extension implementation file to Citrix ADC system. The code listing for mqtt.lua is given below. The example below imports the MQTT extension file hosted on a webserver.
import extension http://10.217.24.48/extensions/mqtt.lua mqtt_code
2. Add a new user TCP based protocol to the system using the extension.
add user protocol MQTT -transport TCP -extension mqtt_code
3. Add a user load balancing vserver and bind backend services to it.
add service mqtt_svr1 10.217.24.48 USER_TCP 1501 add service mqtt_svr2 10.217.24.48 USER_TCP 1502 add lb vserver mqtt_lb USER_TCP –lbmethod USER_TOKEN bind lb vserver mqtt_lb mqtt_svr1 bind lb vserver mqtt_lb mqtt_svr2
4. Add a user vserver for the newly added protocol. Set the defaultlb to the LB vserver configured above.
add user vserver mqtt_vs MQTT 10.217.24.28 8765 -defaultLb mqtt_lb
5. Optionally, enable MQTT session persistence based on ClientID, set the persistence type to USERSESSION.
set lb vserver mqtt_lb -persistenceType USERSESSION