Asynchronous example - long-poll

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 emulates an application that implements a long-poll asynchronous conversation. The application is a demo of a “chat” page. A browser shows the chat page, and sends a request that remains open until a new message is sent to the chat by another user. After such a message is sent:

  • The response is finished.
  • The new message is shown in the browser.
  • The browser sends another request in order to listen for the next message sent to the chat.

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

The following is the Vuser script that VuGen generated after recording the application - before an asynchronous scan was performed. The script contains a series of web_url functions with similar URLs. Since new requests are sent as soon as the previous response is finished, no lr_think_time functions are added between the web_url functions. This help to indicate that this is a long-poll conversation and not a poll conversation.

When the Vuser script runs, requests to the chat application should be sent repeatedly every time a response from the chat application is finished. In addition, requests should be sent in parallel (simultaneously) with other actions performed in the script.

After VuGen performs an asynchronous scan on the script, the modified script looks as follows:

Notice that a web_reg_async_attributes function has been added before the first web_url function that calls the chat application.

Except for the first call the chat application, all other web_url functions that call similar URLs have been commented out.

The Snapshot pane for the remaining web_url function shows that the snapshots for the removed steps now have origin = Polling.

The response times vary greatly as the responses arrive only when another user has sent a chat message. This helps to indicate that this is a long-poll conversation, and not a poll conversation.

Back to top