ロング ポール チャットのようなサービスの負荷テストに取り組んでいます。テストしたいユースケースはかなり単純です。
- ロングポール GET 接続を開く
- POST リクエストを使用してメッセージを送信する
- 手順 1 で開いた接続が同じメッセージを受信したことをアサートする
手順 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 を使用しています