压接口时,需要先登录,所以打算在init里面录制登录的脚本,之前录过http的登录,录完后自动会生成关联函数,但本次录制HTTPS的一直不顺利,录制完后,回放先是报错Error -27776: Server "XXX" shut connection during attempt to negotiate SSL session。解决如下https://blog.csdn.net/flyaway_07/article/details/50298435
一、问题现象:
Action.c(6): Error -27776: Server "XXX" shut connection during attempt to negotiate SSL session [MsgId: MERR-27776]
Action.c(6): Warning -26000: Empty or no response for URL="https://XXX/login?loginTheme=wap_new" [MsgId: MWAR-26000]
Action.c(6): web_submit_data("login") highest severity level was "ERROR", 0 body bytes, 0 header bytes [MsgId: MMSG-26388]
问题原因:
Loadrunner默认发送是通过sockets(将http转换为sockets)发送的,而sockets默认ssl的版本为ssl23.
解决办法:方法1:使用Winlnet replay instead of Sockets(windows only)回放(在runtime-settings中设置)。Winlnet是微软的一个通信引挚,其IE是基于这个通信引挚,Winlnet不支持unix,而且该默式在vuser线程默式不能准确模块网络连接的速度以及连接的数量。
——经我验证,方法1可以解决问题; 此方法会引起Warning -27492: "HttpSendRequest" failed, Windows error code=12031 and retry limit (0) exceeded for 报错(https://blog.csdn.net/mao_xiaoxi/article/details/89680563),所以选用方法2
方法2:增加语句web_set_sockets_option("SSL_VERSION","3");设置使用ssl的版本,即:
web_set_sockets_option("SSL_VERSION","3");
——经我验证,在我的脚本中相应的请求前面设置ssl版本后,问题也可以解决,只是使用的是TLS版本的ssl,即增加如下函数:
web_set_sockets_option("SSL_VERSION","TLS");
具体的设置方法可以参考HP LoadRunner Online Function Reference文档中对函数 web_set_sockets_option的详细解释,其中SSL_VERSION的设置说明如下:
SSL_VERSION The SSL version preferences 2, 3, 2 and 3, TLS.
二、Warning -27492: "HttpSendRequest" failed, Windows error code=12031 and retry limit (0) exceeded for 报错(https://blog.csdn.net/mao_xiaoxi/article/details/89680563)
实际脚本举例
vuser_init()
{
web_set_max_html_param_len("1024");
/* Registering parameter(s) from source task id 122
// {JSESSIONID3} = "939304D9DC8D0AF3784CBACCB8B33A35"
// */
web_reg_save_param("JSESSIONID3",
"LB/IC=jsessionid=",
"RB/IC=\"",
"Ord=1",
"Search=body",
"RelFrameId=1",
LAST);
web_set_sockets_option("SSL_VERSION","TLS");
web_url("login",
"URL=https://×**.300.cn/CAS/login",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t5.inf",
"Mode=HTML",
EXTRARES,
"Url=enterprise-cloud.jpg", ENDITEM,
"Url=icon-all.png", ENDITEM,
LAST);
web_submit_form("login;jsessionid={JSESSIONID3}", //都是录制的,要注意选中此处的,然后右键>Replace with a Parameter>将参数名改为JSESSIONID3>OK.
"Snapshot=t6.inf",
ITEMDATA,
"Name=username", "Value=********", ENDITEM,
"Name=password", "Value=********", ENDITEM,
EXTRARES,
"Url=images/confirm.gif", ENDITEM,
LAST);
return 0;
}