# Difference between some irule

**URL:** <https://community.f5.com/t/difference-between-some-irule/34842>\
**Category:** Technical Forums\
**Tags:** big-ip, irules, application-delivery\
**Created:** [August 15, 2017, 6:06pm UTC](https://community.f5.com/t/difference-between-some-irule/34842 "2017-08-15T18:06:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dineshsankar\_31](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@Dineshsankar\_31](https://community.f5.com/u/Dineshsankar_31)\
**Post date:** [August 15, 2017, 6:06pm UTC](https://community.f5.com/t/difference-between-some-irule/34842/1 "2017-08-15T18:06:50Z")

</div>

difference between “when client accepted” & “when HTTP request”, Give an example.

---

<div class="post-metadata">

**Author:** ![Ed\_Summers](https://avatars.discourse-cdn.com/v4/letter/e/7cd45c/32.png) [@Ed\_Summers](https://community.f5.com/u/Ed_Summers)\
**Post date:** [August 15, 2017, 6:41pm UTC](https://community.f5.com/t/difference-between-some-irule/34842/2 "2017-08-15T18:41:17Z")

</div>

[Client Accepted](https://devcentral.f5.com/Wiki/iRules.CLIENT_ACCEPTED.ashx) - Fires after a connection entered into the connection table. For TCP, after the handshake completes. (text straight from the link)

[HTTP Request](https://devcentral.f5.com/wiki/iRules.HTTP_REQUEST.ashx) - Fires after the system fully parses the complete client HTTP request headers (text straight from the link)

There is a great diagram in [this 101 article by Jason Rahm](https://devcentral.f5.com/articles/the101-irules-101-events-amp-priorities) showing when various events fire.

---

<div class="post-metadata">

**Author:** ![crodriguez](https://avatars.discourse-cdn.com/v4/letter/c/b77776/32.png) [@crodriguez](https://community.f5.com/u/crodriguez)\
**Post date:** [August 15, 2017, 6:48pm UTC](https://community.f5.com/t/difference-between-some-irule/34842/3 "2017-08-15T18:48:04Z")

</div>

CLIENT\_ACCEPTED occurs once per connection to a virtual server. On a TCP connection, CLIENT\_ACCEPTED is triggered after the 3-way handshake is completed.

Once a TCP connection is established, one or more HTTP requests may flow over that connection. If the virtual server has an HTTP profile assigned, the HTTP\_REQUEST event is triggered every time a new HTTP request is received from the client on the virtual server. So while the CLIENT\_ACCEPTED event only occurs once per connection, the HTTP\_REQUEST event _ **may** _ occur multiple times per connection, depending on other network influences, such as browser behavior, HTTP version, and keep-alive settings.

For example, here is a simple iRule that writes log messages on both the CLIENT\_ACCEPTED and HTTP\_REQUEST events:

```tcl
when CLIENT_ACCEPTED {
   log local0. "3-way handshake completed between client at [IP::client_addr] and virtual server at [IP::local_addr]"
}
when HTTP_REQUEST {
   log local0. "Client request for [HTTP::host][HTTP::uri] received from client at [IP::client_addr] to virtual server at [IP::local_addr]"
}

```

Here is the log output when connecting to the virtual server and load balancing to a back end Apache server where **KeepAlive** is set to **Off** :

```tcl
tmm[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : Client request for 10.10.2.101/ received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/css/global.css received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : Client request for 10.10.2.101/js/showCookie.js received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : Client request for 10.10.2.101/images/F5-PNG-Logo.png received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : Client request for 10.10.2.101/images/askf5.jpg received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/images/ihealth.jpg received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : Client request for 10.10.2.101/images/facebook_logo.png received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/images/twitter_logo.png received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/images/background.gif received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : Client request for 10.10.2.101/images/main.png received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : Client request for 10.10.2.101/images/dc.jpg received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : Client request for 10.10.2.101/images/linkedin_logo.png received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : Client request for 10.10.2.101/images/youtube_logo.png received from client at 10.10.2.30 to virtual server at 10.10.2.101

```

Notice there is a separate connection for each HTTP\_REQUEST because the back end server is not honoring the Connection KeepAlive on the request header. Therefore, after each request, the connection is closed, and the browser must establish a new connection to send the next HTTP request. It takes 13 connections to load all 13 page elements.

Here’s the same iRule log output but with KeepAlive set to On on the back end server. Notice that there are multiple connections (as established by the browser) but that multiple HTTP requests flow over each connection. In this case, it takes only 5 connections to load the 13 page elements:

```tcl
tmm1[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/ received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/js/showCookie.js received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/css/global.css received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/images/F5-PNG-Logo.png received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/images/askf5.jpg received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : Client request for 10.10.2.101/images/main.png received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/images/ihealth.jpg received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/images/background.gif received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : 3-way handshake completed between client at 10.10.2.30 and virtual server at 10.10.2.101
tmm[1523]: Rule /Common/test : Client request for 10.10.2.101/images/dc.jpg received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/images/twitter_logo.png received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/images/facebook_logo.png received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/images/linkedin_logo.png received from client at 10.10.2.30 to virtual server at 10.10.2.101
tmm1[1523]: Rule /Common/test : Client request for 10.10.2.101/images/youtube_logo.png received from client at 10.10.2.30 to virtual server at 10.10.2.101

```
