Frequent Contributor.
Frequent Contributor.

How to make periodic poll with different headers and periodic websocket send


I need to make a periodic web call to my web application for keep-alive / heartbeat.

I know there is a web_reg_async_attributes function which allows you to start a periodic poll (Asynchronous Conversations).

Example: Asynchronous Conversations

web_reg_async_attributes("ID=Push_0", "Pattern=Push", "URL={MyServiceURL}", "RequestCB=Push_0_RequestCB", "ResponseHeadersCB=Push_0_ResponseHeadersCB", "ResponseBodyBufferCB=Push_0_ResponseBodyBufferCB", "ResponseCB=Push_0_ResponseCB", LAST);



int Push_0_RequestCB() {
  //enter your implementation for RequestCB() here

  //call web_util_request_set_url() here to modify request url:
  web_util_set_request_url("<request url>");

  //call web_util_set_request_body() here to modify request body:
  web_util_set_request_body("<request body>");

  return WEB_ASYNC_CB_RC_OK;

My issue is that I need to add a header (different in every call), so I can't use

    web_add_header ("MyHeader","{MyHeaderUpdatedValue}");

because it won't modify the recorded async web request.

Another issue is that I want to delay the first poll, so if it has to be polled every 30 seconds, the first call should't be inmediate, but after a 30 seconds... and I don't want to call lr_think_time (30) to wait 30 seconds... obviously because timing will depend on think time configuration, but also because during these 30 seconds I want the script to continue running and not waiting.

Is there a way to implement the desired behaviour?

On the other hand, I need to make another periodic keep-alive call to a remote service by using web_websocket_send. How to implement this with Asynchronous conversations?

Kind regards.


0 Replies
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.