Session Expired Response in JMeter - performance

I am testing particular application using JMeter 2.9.There My test plan is Thread group--> Transaction Controller.Inside that various recorded requests are there.I am using HTTP request defaults,HTTP Cookie manager and HTTP header manager,and a view result tree for validation.I found one token i.e. CSRF token to be correlated and I did correlation.But for a particular request I am finding "Session expired..Login again" response much before the logout request.My transaction flow is to Login--> Search a content-->Logout.
Please help me finding a solution.

Try put the element: HTTP Cookie Manager in Thread Group, first item.

the problem can be in the following areas:
-you were redirected automatically instead of following redirects
-login hasn't succeeded
-the session id has not been successfully passed on to the request after login
The JMeter documentation states this:
I've set up JMeter to sample the same URLs as my browser, why is JMeter not seeing the same responses?
There are various different reasons for this:
Cookies - make sure you added a Cookie Manager. Browsers process cookies unless you set them up otherwise, but JMeter does not process cookies unless you add a Cookie Manager.
User-Agent - the User-Agent is a header that is sent by browsers; it identifies the browser type. Some servers are sensitive to this setting and generate different results for what they think are different browsers. The Header Manager is used to add headers such as User-Agent.
Hidden fields - if you did not use the JMeter Proxy (or other application) to record the test plan, then it is easy to miss hidden fields from forms.
Dynamic field names/content - some servers use varying names for fields. So although the test plan may be correct at the time of creation, it does not work when replayed.
URL rewriting - TBA
from http://wiki.apache.org/jakarta-jmeter/DifferentBehaviour

Related

How to save cookies in jmeter recording and replay

Here i have two questions regarding capturing the cookies through JMeter. I am using JMeter recording to capture the web browser flow . And i have added Cookies Manager under the Test plan (common for all requests) Below is my flow :
launch >select Providers >sign-In
While recording it is capturing the cookies properly . i am able to see in the "Request Data" in "View Results Tree" . But while trying to replay i am not seeing the cookies in the results.
Please let me know if i am missing some settings here.
How this will work when we increase the no of users and run.
Thanks In Advance.
JMeter doesn't record cookies, if you add HTTP Cookie Manager to your Test Plan it will automatically extract the cookies from the application's Set-Cookie response header, parse them, validate and send with Cookie header during the next request.
If you cannot see any cookies the reasons could be in:
Cookies are invalid (i.e. expired, not matching the domain/path)
Your test fails somewhere somehow, i.e. your sign-in request fails because you haven't implemented correlation of the dynamic parameters
Inspect response details using "Response Data" tab of the View Results Tree listener and ensure that your test is doing what it is supposed to be doing as it looks like it doesn't go further than first page in your case

Jmeter Log On in SAP CRM web client Error

I used Jmeter's HTTP(S) Test Script Recorder to record the Log in in SAP CRM Web client. I configured HTTP Cookie Manager using the cookies that I saw in browser developer tools ( MYSAPSSO2, Session ID, Sap-usercontext).
In the same recording test I filled some fields in SAP. I stopped the recording test.
I did it multiple times to see what parameters were dynamic and I realized that wfc-secure-id and C5_confighash and c7_confighash were dynamic. So I used regular expression to extract the dynamic values and I applied it in the requests where I filled the fields.
In View Results Tree I can see the HTML response in the Requests' response bodies that the log in was successful and the fields were filled. I also checked the SAP sessions metrics that the users are logging in.
After the successful login I went and did some recordings of a User roaming around inside the web client performing some operations and saving the results. I changed the dynamic values to fit the previously values I obtained in the login process.
The issue lies in the fact than when i went back to JMeter to do a test run, I get a logon error on the response header between the login and the new recordings. The response body of the new recordings also return empty.
I'm thinking that between the recordings, jmeter is losing the user session information
How can I connect the new records with the log in record?
You should not be hard-coding cookies in the HTTP Cookie Manager.
JMeter doesn't record cookies
headers.removeHeaderNamed(HTTPConstants.HEADER_COOKIE);// Always remove cookies
hence you should not be manually adding the cookies you see in browser to the HTTP Cookie Manager, adding an empty HTTP Cookie Manager should be enough to let JMeter automatically take care of incoming cookies.
If you don't see the cookies being added to the request(s) it usually means that:
Your HTTP Request sampler is not configured properly, i.e. "Server Name or IP" field is empty
Your server is not configured properly (i.e. it returns cookies which doesn't comply with the standard hence JMeter fails to add them)
The steps you could take are:
Enable debug logging for the HTTP Cookie Manager by adding the next line to log4j2.xml file:
<Logger name="org.apache.jmeter.protocol.http.control" level="debug" />
Use less-restrictive cookie policy, i.e. netscape
Add the next line to user.properties file:
CookieManager.check.cookies=false
Check out HTTP Cookie Manager Advanced Usage - A Guide for more information on JMeter's HTTP Cookie Manager usage/troubleshooting

Keep session with Cookies in Jmeter

I am trying to run a simple test in jmeter but i am stuck. The steps are:
Log in
Set the Cookie Manager
Access the landing page
The first 2 steps are successful, but i get status 403 "errorId":"AUTHENTICATION_REQUIRED" on the 3rd step. My guess is it is not getting the session from log in, but everything i 've tried hasn't worked. Here is my test plan:
Any suggestions?
JMeter's HTTP Cookie Manager obeys JMeter Scoping Rules, so if you put it as a child of the Setting Cookies request it will be applied to that request only, therefore cookies will not be available to the Landing Page
Try moving the HTTP Cookie Manager one level higher so your test plan would look like:
You should be able to see which cookies are being received and sent out using View Results Tree listener

Can't get authorized response on requests in JMeter, while they have the same CSRF token and sessionID

I'm having trouble with getting my site normally loaded during the performance testing in Apache JMeter. Firstly I recorded the script (by BadBoy), containing authorization and visiting some pages, unavailable without login. Next, I exported it to JMeter, configured Regular Expression Extractor to get the csrftoken from the request right before the authorization request and it looks like it works just fine:
no errors in http-requests
But if to look at the tab "Response data" of every post-authorized request, the content isn't like correctly loaded page, it just starts page with the empty authorization form, i.e. in some way session is new though all the requests have the same session id and csrftoken in Cookie Data and in Set-Cookie (Sample result), appeared in authorization request result.
HTTP Cookie Manager is added.
Did anyone face this trouble?
UPDATE: I've conducted an experiment with transferring cookies from Chrome to Mozilla Firefox, copied 'csrftoken' and 'session id', and - voila! - it worked, I got the same authorized session in two browsers. Still have no idea what's wrong with JMeter
JMeter automatically treats HTTP Response Codes below 400 as successful, it doesn't perform any checks of response body. Most likely your Regular Expression Extractor failed, add a Debug Sampler and double check resulting variable value.
There could be also the following possible reasons:
You might need to send CSRF token in encoded/escaped form so using i.e. __urlEncode() function will be required. Or vice versa.
Application may expect the token in multiple locations, i.e. not only as a form parameter, but as an extra HTTP Header. In that case you will need to pass it via HTTP Header Manager
You might also want to try the new step-by-step debugger for JMeter to get to the bottom of the issue.
This is the default behavior of this token. 1. make sure where these tokens are passed. It might be passed multiple times. Check the header. Generally, "xref-token" is again passed.
It should be in exact format, decode it if required, also remove , or ; or /. You can also use fiddler.
The solution was found after recording a script by Blazemeter plugin in Chrome and further exporting it in '.JMX' format. Adding an HTTP Header Manager like this (with its special fields, of course) to each HTTP Request solved the problem.

browser session issue in jmeter

Iam testing an application which has the following behaviour
User1 loged into machine A using IE Then User2 cannot login into
Machine A using IE. So User2 should login from Machine B.
I have recorded the script using IE and when trying to test with 10 user load say U1 to U10, only U1 is able to login and rest all are failing....how do i simulatd the load in this case.
I checked with developers and they are not using IP address for this but using browser session for making single user logs in from a single browser.
Could you please help how do i overcome the issue and simulate the load
Try adding HTTP Cookie Manager, it can automatically handle cookies and define and maintain separate session for each thread.
If it doesn't help - inspect requests more closely with a sniffer tool like Wireshark to compare which request bits are different for different users. The possible options are:
Cookies - can be handled by aforementioned HTTP Cookie Manager
Headers - can be handled by HTTP Header Manager
Request parameters - it may be the case when server sends some parameter in the response and expects it to be present in the next request. In that case you need to extract it from the first response with i.e. Regular Expression Extractor, store it into a JMeter Variable and send with the next request.

Resources