Share this page

# web.websocketConnect

Creates a WebSocket connection.

Miscellaneous Functions

## Syntax

                web.websocketConnect( {object} );

## JavaScript Object

    {
        id: "<string>" ,
        uri: "<string>" ,
        origin: "<string>" ,
        secWebSocketKey: "<string>" ,
        secWebSocketProtocol: "<string>" ,
        secWebSocketExtensions: "<string>" ,
        onOpenCB: "<string>" ,
        onMessageCB: "<string>" ,
        onErrorCB: "<string>" ,
        onCloseCB: "<string>" ,
     }

Property Name | Description
--- | ---
id | A unique number indicating the connection number. This value is generated automatically during code generation.
uri | The WebSocket endpoint in ws:// or wss:// (secure WebSocket schema) format.
origin | Origin header value. Optional: Only generated if detected during the recording session.
secWebSocketKey | Sec-WebSocket-Key header value. Optional: The WebSocket key value. Not recorded, but can be added manually.
secWebSocketProtocol | Sec-WebSocket-Protocol header value. Optional: Only generated if detected during the recording session.
secWebSocketextensions | Sec-WebSocket-extensions header value. Optional: Only generated if detected during the recording session.
onOpenCB | Callback function name for an OnOpen event (optional). For details, see WebSocket Callback Functions.
onMessageCB | Callback function name for an OnMessage event (optional). For details, see WebSocket Callback Functions.
onErrorCB | Callback function name for an OnError event (optional). For details, see WebSocket Callback Functions.
onCloseCB | Callback function name for an OnClose event (optional). For details, see WebSocket Callback Functions.

This function creates a WebSocket connection upon which to send the message.

Headers that were detected during recording will be generated automatically, except for SecWebSocketKey. To add additional headers to the handshake request, place web.addHeader or web.addCookie steps before this function.

Callbacks will be generated with the default implementation commented out. For a description of the callback functions, see WebSocket Callback Functions.

## Return Values

Not applicable

## Parameterization

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

## Example

    web.websocketConnect({
       id:0,
       uri:"ws://pumpkin:9876/",
       origin:"http://pumpkin:9876",
       onOpenCB:OnOpenCB0,
       onMessageCB:OnMessageCB0,
       onErrorCB:OnErrorCB0,
       onCloseCB:OnCloseCB0
    });

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: