Need help with chain builder concept

Hello all,

I need some help as I probably do not clearly understand chain builder concept or there is small detail that I missed.

Currently, I’m stuck debugging next very simplified Simulation. All compiles and runs perfectly fine, but request is never sent to the server.

Here is the full Simulation code:

`


class ScnExample extends Simulation {

  val protocol: HttpProtocolBuilder = http
    .baseURL("http://localhost:8080")

  def feed: Iterator[Map[String, Array[Byte]]] = Iterator.continually(Map("packet" -> "{}".getBytes()))

  def request(body: Array[Byte]): HttpRequestBuilder = http("request")
    .post("/api")
    .body(ByteArrayBody(body))

  def chainBuilder: ChainBuilder = exec(session => {
    val packet: Array[Byte] = session.attributes.get("packet").asInstanceOf[Some[Array[Byte]]].get
    request(packet) // request is never sent to the server
    session
  })

  setUp(
    scenario("Example").feed(feed).forever() {
      exec(chainBuilder)
    }
      .inject(atOnceUsers(10))
  )
    .protocols(protocol)

}

`

this code executes request is being generated, but nothing is sent to the server.

`

def chainBuilder: ChainBuilder = exec(session => {
    val packet: Array[Byte] = session.attributes.get("packet").asInstanceOf[Some[Array[Byte]]].get
    request(packet) // request is never sent to the server
    session
  })

`

Thank you so much for any hints,
Stan

Ok, I found what was wrong

This version should work

`

class ScnExample extends Simulation {

  val protocol: HttpProtocolBuilder = http
    .baseURL("[http://localhost:8080](http://localhost:8080/)")

  def feed: Iterator[Map[String, Array[Byte]]] = Iterator.continually(Map("packet" -> "{}".getBytes()))

  def request(): HttpRequestBuilder = http("request")
    .post("/api")
    .body(ByteArrayBody(session =>  session.attributes.get("packet").asInstanceOf[Some[Array[Byte]]].get))

  def chainBuilder: ChainBuilder = exec(

    request()

  )

  setUp(
    scenario("Example").feed(feed).forever() {
      exec(chainBuilder)
    }
      .inject(atOnceUsers(10))
  )
    .protocols(protocol)

}

`