The <cfwebsocket> tag supports a new attribute:
- secure – (Optional) If only secure port (SSL) is configured for the WebSocket server (for web service communication), all the WebSocket communication happens over the secure channel automatically. But in the case if both ports (non-SSL and SSL) are defined , if you require the communication to be set through a secured TCP socket, you must set secure to true. Default is false.
ColdFusion 11 has been enhanced to provide enterprise-level capabilities like real-time message broadcasting across cluster of nodes and SSL support for secure websocket communication (WSS protocol).
Cluster Support
If your application is running across various nodes and on publishing a message to a single node, you want the same to be broadcasted across all the nodes, you can use this feature.
For example, Node1 has two clients (C1 and C2) subscribed to the 'stock' channel. Similarly Node2 has two clients (C4, C6) and Node3 has two clients (C8, C10) also subscribed to the 'stock' channel. When client C1 tries to publish a massage on this 'stock' channel, rather than just sending this message to just C1 and C2 only, the clients from other nodes C4, C6, C8, and C10 must also receive this message.
On using this feature, you can publish a message to all the subscribers of the channel across various nodes of the cluster by enabling cluster. To enable the feature, choose the cluster option and define the multicast port to broadcast node up and node down (events).
Note: The cluster support is not available in the standard edition.
|
JavaScript Functions
The following JavaScript functions were enhanced to auto-support the cluster functionality:
Functions
|
Argument
|
Return Type
|
publish
|
("channelname", messageBody, {filterOptions}
|
boolean
|
getSubscriberCount
|
(“channelname”)
|
boolean
|
invokeAndPublish
|
("channelName", cfcName, cfcMethod, [function_parameter] ,{custom_options})
|
boolean
|
publish
In ColdFusion 10, this function was enabled to send messages to a specific channel based on the filter criteria. In ColdFusion 11, this function is enhanced to send message to all nodes in a cluster by default.
Publish("channelname ", messageBody, {filterOptions});
|
getSubscriberCount
In ColdFusion 10, this function was enabled to get subscriber count from a specific channel based on the filter criteria. In ColdFusion 11, this function is enhanced to fetch the subscriber count from all nodes by default.
getSubscriberCount(“channelname”)
|
invokeAndPublish
Use this function for message publishing and CFC invocation to be executed as separate thread.
invokeandPublish("channelname ", cfcName, cfcMethod, [function_parameter] ,{custom_options})
|
In-built ColdFusion functions
To further facilitate cluster support, the following in-built functions are enhanced for ColdFusion 11:
WSPublish
Trigger a message publish from the server without any input from client. A new parameter "Clustered" has been added to facilitate message broadcasting to all subscribers connected to multiple nodes.
wsPublish(“channel name”, messageBody [clustered])
|
Or
wsPublish(“channel name”, messageBody , {filterOptions},[cluster])
<cfset wsPublish("publishdemochannel","Welcome to publishdemo")/>
|
If the "clustered" parameter is not defined, then the default value will be taken based on the cluster <Enable/Disable> setup.
WSGetSubscribers
Fetches the subscriber information from all the configured nodes. A new parameter "Clustered" has been added to fetch subscriber information from all configured nodes.
WSGetSubscribers("channel")
|
Or
WSGetSubscribers ("channlName" ,[clustered]);
<cfset wsgetSubscribers(“stocks”, true)>
|
If the "clustered" parameter is not defined, then the default value will be taken based on the cluster <Enable/Disable> setup.
WSGetAllChannels
Fetches the sub-channel information from all the configured nodes. A new parameter "Clustered" has been added to fetch sub-channel information from all configured nodes.
WSGetAllChannels ("channel", clustered)
<cfset wsgetAllChannels(“stocks” true,)>
|
If the "clustered" parameter is not defined, then the default value will be taken based on the cluster <Enable/Disable> setup.
Secure WebSocket communication (WebSocket over SSL)
The Websocket screen (Administrator Console > ColdFusion Administrator > Server Settings > WebSocket) has been enhanced in ColdFusion 11 with the following options:
- Enable SSL
- SSL port
- KeyStore File location
- KeyStore password
Option
|
Description
|
Enable SSL
|
Enables Secure Sockets Layer (SSL) for running WebSocket over SSL.
|
KeyStore File location
|
The location of keyStore in server’s file system. For example, C:\OpenSSL\bin\keystore.jks.
|
KeyStore password
|
Password for the keyStore.
|
SSL port
|
Default port is 8543.
|
To enable Web socket cluster from the Administrator node, select Server Setting > Web Socket. In the Web Socket screen, select the Enable Web Socket Cluster check box and enter the Multicast Port details. In the Multicast Port field, the default Multicast Port 45566 is displayed. Change the port details if required. Make sure the multicast port value is same across all the nodes in the cluster.