Share this page

# Asynchronous example - push

For a list of protocols that support asynchronous communication, see 64-bit recording, Async, and IPv6 support.

The following example describes a Vuser script that is developed to emulate a browser displaying an application that utilizes push-type asynchronous conversations. The application is a demo of a “stock quote” page.

The browser shows the page with the stock values, and then sends a request and receives a response with updated stock values. The request remains open until it is closed by the user. For as long as the page is displayed, the server continues to send sub-messages as part of the response - whenever the server has an update for the displayed stocks. Whenever such a sub-message is received by the client, the client displays the updated stock values.

Note: You can modify VuGen's asynchronous request thresholds to assist VuGen in finding push-type conversations. For details, see Using asynchronous request thresholds.

If you attempt to run a script that calls a push url - without first performing an asynchronous scan - the replay will halt while waiting for the response to the highlighted request. After two minutes, VuGen displays an error similar to the following, in the Replay log:

`Action.c(140): Error -27782: Timeout (120 seconds) exceeded while waiting to receive data for URL "http://push.example.com" [MsgId: MERR-27782]`

The error indicates that the response never finished.

Regenerating the script, with Async Scan enabled, creates a script similar to the following:

Copy code

    /* Added by Async CodeGen.
    IO-Push_0
    ScanType = Recording

    The following urls are considered part of this conversation:
        http://push.example.com/sIREAMING_IN_PROGRESS?LS_sessionsS3437Id5eb8f9c6412253451&LS_phase=4903&LS_domain=lights",

    T000 - The following callbacks have been added to AsyncCallbacks.c.
    Add your code to the callback implementations as necessary.
        Push_0_RequestCB
        Push_0_ResponseBodyBufferCB
        Push_0_ResponseCB

    */

    web_reg_async_attributes("ID-Push_0",
        "URL=http://push.example.com/sIREAMING_IN_PROGRESS?LS_sessions(CorrelationParameter)&LS_phase=4903&LS_domain",
        "Pattern=Push",
        "RequestCB=Push_0_RequestCB",
        "ResponseBodyBufferCB=Push_0_ResponseBodyBufferCB",
        "ResponseCB=Push_0_ResponseCB",
        LAST);

    web_url("STREAMING_IN_PROGRESS",
        "URL=http://push.example.com/sIREAMING_IN_PROGRESS?LS_session(CorrelationParameter)&LS_phase=4903&LS_domain",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://www.app.example.com/GNT_StockListDemo_Basic/lightstreamer/lsengine.html",
        "Snapshot=t13.inf",
        "Mode=HTML",
        LAST);

    web_custom_request("control.js",
        "URL=http://push.example.com/lightstreamer/control.js",
        "Method=POST",
        "Resource=0",
        "RecContentType=text/plain",
        "Referer=http://push.example.com/ajax_frame.html?phase=594&domain=example.com&",
        "Snapshot=t14.inf",
        "Mode=HTML",
        "Body=LS_session(CorrelationParameter)&LS_table=1&LS_with_phase=19&LS_reg_phase=311&LS_op=add&LS_mode=NERGE&LS_id=itemI",
        LAST);
    /* Added by Async CodeGen.
    IO = Push_0
    */
        web_stop_async("IO-Push_0",
        LAST);

    return 0

Notice that a web_reg_async_attributes function was added before the web_url function that starts the push conversation, and that a web_stop_async function has been added after the last action step in the script. The script will now run successfully. The push conversation will remain active – running in parallel with the other script functions – until the web_stop_async function, or until the end of the script is reached.

Note that during the Async scan, VuGen did not remove (comment-out) any of the generated code in the Vuser script.

Back to top

https://admhelp.microfocus.com VuGen,Professional Performance Engineering,Performance Engineering for Developers 8942
Tips to improve your search results... OpenText™ Virtual User Generator Help Center OpenText™ VuGen Help 25.1-25.3 All View Local Help Center View Online Help Center Version: