Sends a message over a WebSocket connection.

Example Miscellaneous Functions


            web.websocketSend( {object} );

JavaScript Object

    id: "<string>" ,
    buffer: "<string>" ,
    bufferBin: "<string>" ,
    bufferFile: "<string>" ,
    isBinary: "<string>" ,
Property Name
id The id of the connection over which to send the message.
buffer The string to send to the server.

The binary representation of the string to send to the server.

Note: At least one of the arguments buffer or bufferBin must be present.

bufferFile The pathname or UNC path of the file to send. If the file is stored in the script directory, pass the filename. For example, "c:\myfolder\myfile.txt", "\\mymachine\mysharedfolder\myfile.txt"

Indicates if the message sent by the API is binary (1, yes, true, or on) or text (0, no, false, or off).

Note: This message string is converted as indicated by this argument. For example, if bufferBin is "\x61\x62\x63\x64\x65” and isbinary is "0", the buffer is sent as text.

This function sends the contents of the specified buffer or the specified file to the server with the specified id, using the WebSocket protocol.

To see runtime or post-run statistics generated by this function, use the WebSocket Statistics monitor under the Web resource graphs. You access this graph from the Controller Run tab. The graph shows the following measurements: New Connections per second, Bytes Sent per second, Bytes Received per second, and failed Connections per second.

You can add lr.thinkTime calls between web.websocketSend steps to allow the protocol to complete send and receive operations.

If this function fails, it triggers an onErrorCB callback. For a list of the callback functions, see WebSocket Callback Functions.

Return Values

Not applicable


Standard Parameterization is supported for all of this function's arguments.


   buffer:"sample text message",

See also: WebSocket Callback Functions