Web Vuser Functions (WEB) > Alphabetical List of Web Vuser Functions > web_websocket_send


Sends a message over a WebSocket connection.

C Language

int web_websocket_send("ID=connection ID", ["Buffer=message_Text",] ["Buffer/BIN=message_Text",]  ["Buffer/File=file",] "IsBinary=0/1", LAST);
Example: web_websocket_connect, web_websocket_close, web_websocket_send Miscellaneous Functions
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 Buffer/BIN must be present.

Buffer/File 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: The message string is converted as indicated by this argument. For example, for web_websocket_send( “ID=0”, “Buffer/BIN=\x61\x62\x63\x64\x65”, “IsBinary=0”, LAST), the bufferis sent as text.

LAST Required marker for the end of the argument list.

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 run-time or post-run statistics generated by this function, use the WebSocket Statistics monitor under the Web Resource graphs. You access this graph from the LoadRunner 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_think_time calls between web_websocket_send 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

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.


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