Highlighted
Respected Contributor.
Respected Contributor.
3442 views

Send TCP request in LoadRunner

Jump to solution

I am sending a request to server using JMeter TCP sampler I am able to see correct response from the server. Also checked in server logs the logs contains only the body data I'm sending without any headers.

But when I tried to create the request in LR(web HTTP/HTML protocol) using web_custom_request shown as below,

web_custom_request("web_custom_request",
"URL=http://someIP:port",
"Method=POST",
"Body=<XML><MessageType>...</XML>", LAST);

I'm getting error response for the above request. After checking into server logs the headers are also present due to which server gave an error response.

Request captured in server log (JMeter😞

<XML><MessageType>...</XML>

Request captured in server log (LoadRunner😞

POST / HTTP/1.1

Content-Type: application/x-www-form-urlencoded

Cache-Control: no-cache

User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)

Accept: */*

Connection: close

Host: IP:Port

Content-Length: 721

<XML><MessageType>...</XML>

Please suggest me how can I send the request to the server without any headers.

*NOTE: The protocol used is TCP for client-server

0 Likes
1 Solution

Accepted Solutions
Respected Contributor.
Respected Contributor.

Re: Send TCP request in LoadRunner

Jump to solution

I have found the below approach which worked,

1) To create connection: lrs_create_socket("socket2", "TCP", "RemoteHost=IP:PORT",  LrsLastArg);

2) To send data: lrs_send("socket2", "buf4", LrsLastArg);

3) To Receive Data: lrs_receive("socket2", "buf5", LrsLastArg);

4) To corealate parameter:  lrs_save_searched_string("socket1", LRS_LAST_RECEIVED, "ticket", "LB/BIN=>", "RB/BIN=<", 27, 0, -1);

5) To close the connection: lrs_close_socket("socket2");

Created the buffer values in data.ws in the Extra files.

View solution in original post

11 Replies
Highlighted
Respected Contributor.
Respected Contributor.

Re: Send TCP request in LoadRunner

Jump to solution

I have used below funtion to remove the header,

    web_remove_auto_header("Cache-Control","ImplicitGen=No",LAST);
    web_remove_auto_header("User-Agent","ImplicitGen=No",LAST);
    web_remove_auto_header("Content-Type","ImplicitGen=No",LAST);
    web_remove_auto_header("Accept","ImplicitGen=No",LAST);
    web_remove_auto_header("Connection","ImplicitGen=No",LAST);
    web_remove_auto_header("Host","ImplicitGen=No",LAST);
    web_remove_auto_header("Content-Length","ImplicitGen=No",LAST);

but still unable to remove.

POST / HTTP/1.1

Please suggest me some solution as I have tight guidelines to finish this.

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Send TCP request in LoadRunner

Jump to solution

When I understand you right, you are using with JMeter a TCP request. But by using web_* functions you are using in LR the Web protocol, this is something differently than bare TCP. You might try the Windows Sockets Vuser functions / protocol (lrs_*).

Signature:
Reward community members who take time to respond and help.
0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Re: Send TCP request in LoadRunner

Jump to solution

Hi JHF,

As per your comment I have tried using Windows Socket protocol and lrs_send function but I am not able to figure out how to send the XML request using the function. Can you please elaborate how can I send in lrs_send() function?

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Send TCP request in LoadRunner

Jump to solution

To answer your question I've to go to the LR help. So what about make a Window Socket recording and examine the generated code and translate that to your XML request.

Signature:
Reward community members who take time to respond and help.
0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Re: Send TCP request in LoadRunner

Jump to solution

Hi JHF,

I'm going through the Function reference but having difficulty in understanding.

My aim is to send a XML request to an IP:PORT, could you please assist me in selecting the proper function in Windows sockets to send the XML request. 

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Send TCP request in LoadRunner

Jump to solution

No, i've no time to figure out these things.

Many someone else has examples that can be shared.

Experimenting is the best way to learn and understand. The LR help is not that great that you will find all the details you need unfortunate.

Signature:
Reward community members who take time to respond and help.
0 Likes
Respected Contributor.
Respected Contributor.

Re: Send TCP request in LoadRunner

Jump to solution

I have found the below approach which worked,

1) To create connection: lrs_create_socket("socket2", "TCP", "RemoteHost=IP:PORT",  LrsLastArg);

2) To send data: lrs_send("socket2", "buf4", LrsLastArg);

3) To Receive Data: lrs_receive("socket2", "buf5", LrsLastArg);

4) To corealate parameter:  lrs_save_searched_string("socket1", LRS_LAST_RECEIVED, "ticket", "LB/BIN=>", "RB/BIN=<", 27, 0, -1);

5) To close the connection: lrs_close_socket("socket2");

Created the buffer values in data.ws in the Extra files.

View solution in original post

Highlighted
New Member.

Re: Send TCP request in LoadRunner

Jump to solution

Hi Saurab ,
i face exactly same issue. and i got struck following yoiur method, whehre should i need to insert the xml ?

0 Likes
Highlighted
New Member.

Re: Send TCP request in LoadRunner

Jump to solution

If you can eloborate in detail , it would be really greatful 

 

 

thanks ,

Hari

0 Likes
Highlighted
Visitor.

Re: Send TCP request in LoadRunner

Jump to solution

Hello Saurabh,

I am also facing this issue and cant get solution.
Can u help me with the settings of TCP request and send xml message.

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Send TCP request in LoadRunner

Jump to solution

TCP protocol works with buffers. The argument "buf4" in lrs_send() referse to such a buffer (message of saurab_n at 04-16-2018)  You need to consult the HPE LoadRunner User Guide for more details: "Windows Sockets Data". It is a little tricky to build your socket script by hand and use those 'user buffers'.

But there is a function that let you overrule the named send buffer for the very next call to lrs_send(). It might be the easiest way to go forward with simple socket scripts. A quote from the LR-function help: The lrs_set_send_buffer function specifies the buffer to send in the next call to lrs_send. The buffer specified in lrs_set_send_buffer is sent, and not the buffer designated in the lrs_send function.

Succes, Erik

Signature:
Reward community members who take time to respond and help.
0 Likes
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.