环境:JDK8, Jmeter:3.2
我正在使用HC4CookieManager(唯一可用的选项)。
我使用Basic Auth发出请求,然后我恢复了auth cookie。 不幸的是我的服务器没有设置域(Domain =;)。
结果(我认为)HC4CookieManager完全忽略了cookie,导致我无法在服务器上执行操作。
我在日志中看到了这个错误:
2017-09-12 13:06:41,190 ERROR o.a.j.p.h.c.HC4CookieHandler: Unable to add the cookie
org.apache.http.cookie.MalformedCookieException: Blank value for domain attribute
at org.apache.http.impl.cookie.RFC2109DomainHandler.parse(RFC2109DomainHandler.java:61) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.cookie.PublicSuffixDomainFilter.parse(PublicSuffixDomainFilter.java:113) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.cookie.CookieSpecBase.parse(CookieSpecBase.java:113) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.cookie.DefaultCookieSpec.parse(DefaultCookieSpec.java:145) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.jmeter.protocol.http.control.HC4CookieHandler.addCookieFromHeader(HC4CookieHandler.java:125) [ApacheJMeter_http.jar:3.2 r1790748]
at org.apache.jmeter.protocol.http.control.CookieManager.addCookieFromHeader(CookieManager.java:373) [ApacheJMeter_http.jar:3.2 r1790748]
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.saveConnectionCookies(HTTPHC4Impl.java:1519) [ApacheJMeter_http.jar:3.2 r1790748]
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:485) [ApacheJMeter_http.jar:3.2 r1790748]
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74) [ApacheJMeter_http.jar:3.2 r1790748]
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1189) [ApacheJMeter_http.jar:3.2 r1790748]
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1178) [ApacheJMeter_http.jar:3.2 r1790748]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:491) [ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:425) [ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:254) [ApacheJMeter_core.jar:3.2 r1790748]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_102]
2017-09-12 13:06:41,327 ERROR o.a.j.p.h.c.HC4CookieHandler: Unable to add the cookie
这有解决方法吗?我尝试过JDK7的结果相同。
答案 0 :(得分:0)
您可以将以下行添加到 user.properties 文件中:
CookieManager.check.cookies=false
并重新启动JMeter以选择该属性。
根据HTTP Cookie Manager documentation:
JMeter检查收到的cookie是否对URL有效。这意味着不存储跨域cookie。如果您有行为错误或想要使用跨域cookie,请定义JMeter属性“CookieManager.check.cookies = false”。
因此,如果上述属性设置为false