question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scenario is not replaying set cookies

See original GitHub issue

I’m currently running 1.6.0-23.

I am assuming I am just misunderstanding something but I can’t get auth cookies that the server is setting to be replayed by subsequent requests later in the scenario. When a user successfully logs into our api we return an HttpOnly cookie called Fuze. So I have the following configuration:

config:
  payload:
    path: "logins.csv"
    fields:
      - "username"
      - "password"
  phases:
    - duration: 300
      arrivalRate: 1
scenarios:
  - name: "Test"
    flow:
      - post:
          url: "/login"
          json:
            Email: "{{ username }}"
            Password: "{{ password }}"            
      - get:
          url: "/message/get-message-count" 

With debug output I"m getting the following:

\   http request: {
  "url": "http://localhost:46551/login",
  "method": "POST",
  "headers": {
    "user-agent": "Artillery (https://artillery.io)"
  },
  "json": {
    "Email": "dev",
    "Password": "xxx"
  }
} +807ms
  http:response {
  http:response   "cache-control": "no-cache",
  http:response   "pragma": "no-cache",
  http:response   "content-type": "application/json; charset=utf-8",
  http:response   "expires": "-1",
  http:response   "server": "Microsoft-IIS/10.0",
  http:response   "unauthenticateduser": "true",
  http:response   "x-aspnet-version": "4.0.30319",
  http:response   "set-cookie": [
  http:response     "Fuze=66DEF75C1CFA4A5691E24A4D37BA7AFF837C5A9F6BC255BAA25DA894080720F6C6C12917FAB059C3D0DB80A204E9FAEB9F95860B30D37C807A66ECAB5747ADD788E3AE01D1F608DCE473933779BA060670B9B1915363EAD7073A94A0C1D0E5A0FDEEA5E45720E3B38EE155E9718C91A6A11084CED1BE5D67ABF00F61E21AB1C10BD1DF71076112F590F767EC57B7E510100C6824FC73C14ED54E60CC70800A6B15A7ACCA; domain=localhost; expires=Tue, 11-Sep-2018 22:36:22 GMT; path=/; HttpOnly",
  http:response     "profile=29; domain=localhost; path=/; HttpOnly"
  http:response   ],
  http:response   "x-sourcefiles": "=?UTF-8?B?QzpcY29kZVx3b3JrXGNhcmVzdGFja1xDYXJlU3RhY2suVW5pZmllZC5tc2hhcGlyb1xDYXJlU3RhY2suQmFja2VuZFxDYXJlU3RhY2suV2ViXGxvZ2lu?=",
  http:response   "x-powered-by": "ASP.NET",
  http:response   "date": "Tue, 11 Sep 2018 22:00:21 GMT",
  http:response   "content-length": "42"
  http:response } +1ms
  http:response {
  http:response   "Version": "v2.7.0",
  http:response   "IsLoginSuccess": true
  http:response } +16ms
  http captures and matches: +2ms
  http {} +1ms
  http {} +2ms
  http request: {
  "url": "http://localhost:46551/message/get-message-count",
  "method": "GET",
  "headers": {
    "user-agent": "Artillery (https://artillery.io)"
  }
} +14ms
  http:response {
  http:response   "cache-control": "no-cache",
  http:response   "pragma": "no-cache",
  http:response   "content-type": "application/json; charset=utf-8",
  http:response   "expires": "-1",
  http:response   "server": "Microsoft-IIS/10.0",
  http:response   "unauthenticateduser": "true",
  http:response   "x-aspnet-version": "4.0.30319",
  http:response   "x-sourcefiles": "=?UTF-8?B?QzpcY29kZVx3b3JrXGNhcmVzdGFja1xDYXJlU3RhY2suVW5pZmllZC5tc2hhcGlyb1xDYXJlU3RhY2suQmFja2VuZFxDYXJlU3RhY2suV2ViXG1lc3NhZ2VcZ2V0LW1lc3NhZ2UtY291bnQ=?=",
  http:response   "x-powered-by": "ASP.NET",
  http:response   "date": "Tue, 11 Sep 2018 22:00:21 GMT",
  http:response   "content-length": "61"
  http:response } +1ms
  http:response "{\"Message\":\"Authorization has been denied for this request.\"}" +2ms
  http captures and matches: +8ms
  http {} +2ms
  http {} +1ms

From this it shows artillery submitting a request to /login and the server response containing a Fuze cookie. However the next request in the same scenario shows no cookies being sent which results in a 401 being returned (which is expected when not logged in).

Reading the documentation shows

Cookies are remembered and re-used by individual virtual users.

This makes me think that any cookie that the server sets should be automatically replayed by Artillery. Am I missing something?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
hassycommented, Nov 30, 2021

hi @johnoraclestites 👋 that behavior is indeed expected. cookies would be considered virtual user-specific data and as such do not get passed from a before block to individual VUs.

0reactions
johnoraclestitescommented, Nov 29, 2021

using version 2.0, I have an authentication post request in a scenario that is correctly saving and replaying the returned cookie for all subsequent requests in the flow, but if I move that authentication post to the before section of the overall script, the cookies are not sent. is this expected?

Read more comments on GitHub >

github_iconTop Results From Across the Web

php - Why are my cookies not setting? - Stack Overflow
The problem comes from the fact that setcookie() doesn't set the cookies immediately, it sends the headers so the browser sets the cookies....
Read more >
Set-Cookie - HTTP - MDN Web Docs
The Set-Cookie HTTP response header is used to send a cookie from the server ... to the client the cookie is being set...
Read more >
Cookies, document.cookie - The Modern JavaScript Tutorial
A write operation to document.cookie updates only cookies mentioned in it, but doesn't touch other cookies. For instance, this call sets a ...
Read more >
NCPRE Research Role-playing Scenarios
Role-Play Scenarios for Teaching Responsible Conduct of Research: Assessment of Outcomes. About Cookies. Copyright · Privacy Policy.
Read more >
Upcoming changes in cookie handling in Google Chrome
If your application is used in cross-site scenarios and it sets cookies using the platform's JavaScript extensibility (i.e. you're setting ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found