# LB\_SELECTED and HTTP commands - warning

**URL:** <https://community.f5.com/t/lb-selected-and-http-commands-warning/54201>\
**Category:** Technical Forums\
**Tags:** irules, devops, ltm, application-delivery, tcl-error\
**Created:** [May 27, 2017, 9:36am UTC](https://community.f5.com/t/lb-selected-and-http-commands-warning/54201 "2017-05-27T09:36:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dragonflymr](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dragonflymr](https://community.f5.com/u/dragonflymr)\
**Post date:** [May 27, 2017, 9:36am UTC](https://community.f5.com/t/lb-selected-and-http-commands-warning/54201/1 "2017-05-27T09:36:29Z")

</div>

Hi,

It took me off guard when doing some test with TCP profile. Be advised that under some conditions HTTP type commands may generate TCL error like that:

**TCL error: /Common/host\_change\_member - Illegal argument. Can’t execute in the current context. (line 1) invoked from within “HTTP::host”**

It was caused by such code:

```tcl
when LB_SELECTED {
    if { [LB::server addr] eq "10.128.30.110" } {
        set host "host1.test.com"       
    } else {
        set host "host2.test.com"
    }
    HTTP::header replace Host $host
}

```

Pretty safe code I guess, but…

If for some reason LB\_SELECTED is triggered when no HTTP request is received, then mentioned error will be logged and of course connection will be reset.

I don’t know other conditions causing this except:

In TCP profile enable Verified Accept

Above option seems to be rather dangerous for standard type VS (especially HTTP) as it breaks standard LB logic.

Instead of performing LB decision after successful client side 3WHS and first HTTP request received it performs LB after receiving SYN packet from client.

To avoid this problem it’s better to perform HTTP related operations (that have to be based on some data collected during LB\_SELECTED which is triggered after HTTP\_REQUEST) in HTTP\_REQUEST\_RELEASE.

Piotr

---

<div class="post-metadata">

**Author:** ![Samir\_Jha\_52506](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Samir\_Jha\_52506](https://community.f5.com/u/Samir_Jha_52506)\
**Post date:** [May 28, 2017, 8:11am UTC](https://community.f5.com/t/lb-selected-and-http-commands-warning/54201/2 "2017-05-28T08:11:18Z")

</div>

Agree with your point. In above iRule **LB\_SELECTED** works till selection but when you apply header replacement, it comes under HTTP related iRule method . That is the reason it will give error. thanks for posting your comments. I appreciate!!

---

<div class="post-metadata">

**Author:** ![dragonflymr](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dragonflymr](https://community.f5.com/u/dragonflymr)\
**Post date:** [May 28, 2017, 2:15pm UTC](https://community.f5.com/t/lb-selected-and-http-commands-warning/54201/3 "2017-05-28T14:15:40Z")

</div>

Hi,

Glad you found it helpful. I did benefit so many times from posts on the forum so I think is fair to contribute if possible.

Piotr

---

<div class="post-metadata">

**Author:** ![JG](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@JG](https://community.f5.com/u/JG)\
**Post date:** [May 29, 2017, 2:35am UTC](https://community.f5.com/t/lb-selected-and-http-commands-warning/54201/4 "2017-05-29T02:35:17Z")

</div>

Thanks for sharing!

---

<div class="post-metadata">

**Author:** ![stan\_piron](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@stan\_piron](https://community.f5.com/u/stan_piron)\
**Post date:** [May 29, 2017, 4:57am UTC](https://community.f5.com/t/lb-selected-and-http-commands-warning/54201/5 "2017-05-29T04:57:53Z")

</div>

Hi Piotr,

There are 2 HTTP events in server side context :

- HTTP\_REQUEST\_SEND
- HTTP\_REQUEST\_RELEASE

you can use both but some http commands are not supported in HTTP\_REQUEST\_RELEASE
