# Close connection on each iteration

**URL:** <https://community.gatling.io/t/close-connection-on-each-iteration/5064>\
**Category:** Gatling (Open-Source)\
**Created:** [June 5, 2019, 12:36pm UTC](https://community.gatling.io/t/close-connection-on-each-iteration/5064 "2019-06-05T12:36:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leon\_Sery](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@Leon\_Sery](https://community.gatling.io/u/Leon_Sery)\
**Post date:** [June 5, 2019, 12:36pm UTC](https://community.gatling.io/t/close-connection-on-each-iteration/5064/1 "2019-06-05T12:36:43Z")

</div>

Hi,  
Is gatling have an ability to close connection on each iteration (like in LoadRunner)?  
We want to emulate is real behavior of our client.

Thanks,  
Leon

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [June 6, 2019, 6:08am UTC](https://community.gatling.io/t/close-connection-on-each-iteration/5064/2 "2019-06-06T06:08:09Z")

</div>

Don’t try to think the LoadRunner way. Learn Gatling.

With Gatling, you don’t want to iterate and recycle users, it doesn’t make sense. You want to start a fresh one.  
Each virtual user has its own connection pool that gets closed when user terminates.

---

<div class="post-metadata">

**Author:** ![Leon\_Sery](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@Leon\_Sery](https://community.gatling.io/u/Leon_Sery)\
**Post date:** [June 6, 2019, 7:35am UTC](https://community.gatling.io/t/close-connection-on-each-iteration/5064/3 "2019-06-06T07:35:30Z")

</div>

Thanks Stephane!  
I don’t trying to recycle users 🙂  
I need to achieve the following simple scenario:

1. Open connection
2. Sending 1 http request
3. Closing connection
4. Do this in iterations with many concurrent connections
5. In total I need about 6000 requests per sec  
Actually I need that request rate will equal to create/close connections rate.  
What is a way to achieve this with Gatling?

Thanks,  
Leon

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [June 6, 2019, 8:09am UTC](https://community.gatling.io/t/close-connection-on-each-iteration/5064/4 "2019-06-06T08:09:23Z")

</div>

Standard HTTP behavior:

[https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.10](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.10)

HTTP/1.1 defines the “close” connection option for the sender to signal that the connection will be closed after completion of the response. For example,

```auto
       Connection: close

```

---

<div class="post-metadata">

**Author:** ![Leon\_Sery](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@Leon\_Sery](https://community.gatling.io/u/Leon_Sery)\
**Post date:** [June 6, 2019, 8:13am UTC](https://community.gatling.io/t/close-connection-on-each-iteration/5064/5 "2019-06-06T08:13:41Z")

</div>

You are right! This header will explain to server that client may to close connection.  
But this will NOT close connection!!!  
The connection should be closed by my client explicitly…

Leron

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [June 6, 2019, 8:22am UTC](https://community.gatling.io/t/close-connection-on-each-iteration/5064/6 "2019-06-06T08:22:17Z")

</div>

in either **the request** or the response header fields indicates that the connection SHOULD NOT be considered `persistent’ (section 8.1) after the current request/response is complete…

Connection: close notifies the peer that the emitting side is going to close the connection.

---

<div class="post-metadata">

**Author:** ![Leon\_Sery](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@Leon\_Sery](https://community.gatling.io/u/Leon_Sery)\
**Post date:** [June 6, 2019, 8:38am UTC](https://community.gatling.io/t/close-connection-on-each-iteration/5064/7 "2019-06-06T08:38:58Z")

</div>

Yes, of course. Peer (client) notifies the peer (server) that is going to close connection.  
But actually it is not. As far as I verified, gatling **doesn’t close connection** , even this header is set.

Leon

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [June 6, 2019, 9:01am UTC](https://community.gatling.io/t/close-connection-on-each-iteration/5064/8 "2019-06-06T09:01:52Z")

</div>

Ah ah, that’s indeed a stupid bug: [https://github.com/gatling/gatling/issues/3746](https://github.com/gatling/gatling/issues/3746)

Thanks for reporting!

---

<div class="post-metadata">

**Author:** ![Leon\_Sery](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@Leon\_Sery](https://community.gatling.io/u/Leon_Sery)\
**Post date:** [June 6, 2019, 9:06am UTC](https://community.gatling.io/t/close-connection-on-each-iteration/5064/9 "2019-06-06T09:06:40Z")

</div>

Wow! You are the best!  
When we can expect for the fix? We will very appreciate this, because we already got stuck on this issue about 2 weeks…

Leon

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [June 6, 2019, 9:30am UTC](https://community.gatling.io/t/close-connection-on-each-iteration/5064/10 "2019-06-06T09:30:02Z")

</div>

We plan on releasing Gatling 3.2.0 mid-July along with FrontLine 1.8.0.  
We might release a 3.1.3 before that if we hit a blocker for our customers, but there’s no such such plan atm.  
If you can’t wait, you’ll have to build from sources.

Regards,
