我正在为我的长轮询聊天服务进行负载测试。我想测试的用例非常简单:
我设法实现了第1步和第2步(我可以在服务器访问日志中看到发出了请求)但是在第3步我遇到了以下错误:
错误-27653:尝试从未连接的套接字读取(“连接: 关闭“指定但未检测到服务器端关闭”。 URL =“https:// {Env} / chat / poll /”[MsgId:MERR-27653]
警告-27764:请求“https:// {Env} / chat / poll /”失败[在Action.c(76)发布] [MsgId:MWAR-27764]
我可以将异步请求与阻止请求结合使用吗?
我的测试代码是
int done;
Action()
{
int HttpRetCode;
int i = 5;
// Initialize the global done state variable, and start the async transaction variable
done = 0;
lr_start_transaction("async-call");
// Define the request to be handled asynchronously
// Specify the callback functions that will be called when the response is returned.
// The callback functions are defined below.
web_reg_async_attributes("ID=Poll_0",
"URL=https://{Env}/chat/poll/",
"Pattern=LongPoll",
"PollIntervalMs=200",
"RequestCB=Poll_0_RequestCB",
"ResponseBodyBufferCB=Poll_0_ResponseBodyBufferCB",
"ResponseCB=Poll_0_ResponseCB",
LAST);
// now make the async call.
// note that the script will not block on this call. processing will continue on past this step while the request is handles asynchronously
web_url("Poll_0",
"URL=https://{Env}/chat/poll/",
"Resource=1",
LAST);
lr_force_think_time(10);
// Send interop message
lr_message("Send interop message");
lr_start_transaction("/chat/.POST.201");
web_add_header("X-Session-ID", "sessionA");
web_custom_request("Push interop message",
"URL=https://{Env}/chat/",
"Method=POST",
"Resource=0",
"Mode=HTTP",
"Body=DJIGURDA",
LAST);
HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
if (HttpRetCode != 201) {
lr_error_message("Unexpected return code: %d", HttpRetCode);
lr_end_transaction("/chat/.POST.201", LR_FAIL);
} else {ev
lr_end_transaction("/chat/.POST.201", LR_AUTO);
}
lr_message("Waiting for response");
// To capture the response time of the async call, wait until the callback is called.
// Without this, the script would move past and complete the iteration before the callback is called.
//web_sync("ParamCreated=ready","RetryIntervalMs=18000","RetryTimeoutMs=3600000",LAST);
// To capture the response time of the async call, wait until the callback is called.
// Without this, the script would move past and complete the iteration before the callback is called.
while (done==0 && i-- > 0)
{
lr_force_think_time(1);
}
// once the callback has been called, end the transaction to get the response time.
lr_end_transaction("async-call", LR_AUTO);
// stop the polling
web_stop_async("ID=Poll_0",
LAST);
return 0;
}
/*
* Callback Implementation
*
*
*/
int Poll_0_RequestCB()
{
//enter your implementation for RequestCB() here
lr_message("in Poll_0_RequestCB request callback");
return WEB_ASYNC_CB_RC_OK;
}
int Poll_0_ResponseBodyBufferCB(
const char * aLastBufferStr,
int aLastBufferLen,
const char * aAccumulatedStr,
int aHttpStatusCode)
{
//enter your implementation for ResponseBodyBufferCB() here
// when the response is received, update the global variable
done = 1;
// print out the response body and length
lr_message("in Poll_0_ResponseBodyBufferCB response body callback");
lr_message("in Poll_0_ResponseBodyBufferCB response body callback, lastBufferLen=%d", aLastBufferLen);
return WEB_ASYNC_CB_RC_OK;
}
int Poll_0_ResponseCB(
const char * aResponseHeadersStr,
int aResponseHeadersLen,
const char * aResponseBodyStr,
int aResponseBodyLen,
int aHttpStatusCode)
{
//enter your implementation for ResponseCB() here
lr_message("in Poll_0_ResponseCB response callback, headerLen=%d, bodyLen=%d", aResponseHeadersLen, aResponseBodyLen);
lr_message("in Poll_0_ResponseCB response callback, header=%s", aResponseHeadersStr);
lr_message("in Poll_0_ResponseCB response callback, body=%s", aResponseBodyStr);
return WEB_ASYNC_CB_RC_OK;
}
日志输出为:
Action.c(19): Notify: Transaction "async-call" started.
Action.c(25): web_reg_async_attributes started [MsgId: MMSG-26355]
Action.c(25): Warning -26318: When "Pattern" is not "Poll", "PollIntervalMs" is ignored [MsgId: MWAR-26318]
Action.c(25): web_reg_async_attributes highest severity level was "warning" [MsgId: MMSG-26391]
Action.c(36): web_url("Poll_0") started [MsgId: MMSG-26355]
Action.c(36): "ID=poll_0" && "Pattern=LongPoll" now applied to URL="https://{Env}/chat/poll/" (RelFrameId=1, Internal ID=3) [MsgId: MMSG-35172]
in Poll_0_RequestCB request callback
Action.c(36): Retaining cross-step download of URL="https://{Env}/chat/poll/" (RelFrameId=1, Internal ID=3) [MsgId: MMSG-27658]
Action.c(36): web_url("Poll_0") was successful, 0 body bytes, 0 header bytes [MsgId: MMSG-26386]
Action.c(41): lr_force_think_time: 10.00 seconds.
Send interop message
Action.c(46): Notify: Transaction "/chat/.POST.201" started.
Action.c(48): web_add_header("X-Session-ID") started [MsgId: MMSG-26355]
Action.c(48): web_add_header("X-Session-ID") was successful [MsgId: MMSG-26392]
Action.c(50): web_custom_request("Push interop message") started [MsgId: MMSG-26355]
Action.c(50): Retaining cross-step download of URL="https://{Env}/chat/poll/" (RelFrameId=1, Internal ID=3) [MsgId: MMSG-27658]
Action.c(50): Retaining cross-step download of URL="https://{Env}/chat/poll/" (RelFrameId=1, Internal ID=3) [MsgId: MMSG-27658]
Action.c(50): Retaining cross-step download of URL="https://{Env}/chat/poll/" (RelFrameId=1, Internal ID=3) [MsgId: MMSG-27658]
Action.c(50): web_custom_request("Push interop message") was successful, 0 body bytes, 377 header bytes [MsgId: MMSG-26386]
Action.c(58): web_get_int_property started [MsgId: MMSG-26355]
Action.c(58): web_get_int_property was successful [MsgId: MMSG-26392]
Action.c(64): Notify: Transaction "/chat/.POST.201" ended with "Pass" status (Duration: 1.3904 Wasted Time: 0.0033).
Waiting for response
Action.c(76): lr_force_think_time: 1.00 seconds.
Action.c(76): Error -27653: Attempted read from an unconnected socket ("Connection: close" specified but server-side closure not detected). URL="https://{Env}/chat/poll/" [MsgId: MERR-27653]
Action.c(36): Warning -27764: Request "https://{Env}/chat/poll/" failed [issued at Action.c(76)] [MsgId: MWAR-27764]
Action.c(76): Notify: Deleting Conversation Information with ID="poll_0"
Action.c(76): lr_force_think_time: 1.00 seconds.
Action.c(76): lr_force_think_time: 1.00 seconds.
Action.c(76): lr_force_think_time: 1.00 seconds.
Action.c(76): lr_force_think_time: 1.00 seconds.
Action.c(80): Notify: Transaction "async-call" ended with "Pass" status (Duration: 19.0076 Think Time: 16.5943 Wasted Time: 0.0043).
Action.c(83): web_stop_async started [MsgId: MMSG-26355]
Action.c(83): Warning -26000: Failed to find conversation with ID="poll_0" for stopping [MsgId: MWAR-26000]
Action.c(83): web_stop_async highest severity level was "warning" [MsgId: MMSG-26391]
Ending action Action.
我正在使用VuGen 11.52和C API