Regarding gatling InputStreamBody

Hello,

gatling version - 2.2.5
scala version - 2.11.8

My plan is to post audio file but instead of posting as a file I want to stream it so I implement the below code which sends a chunk but not sure how to incorporate it in gatling, any help be appreciated.

I have tried this but not sure if I am streaming or not, plus i get “o.a.e.RemotelyClosedException: Remotely closed” this error after 90 successful requests.

def listOfFileStreams(directoryPath:String): Array[Map[String, InputStream]] = {
  val arr = new File(directoryPath).listFiles
  val inStream = new Array[Map[String, InputStream]](arr.length)
  var count = 0
  var fileIndex = 0
  var inStreamMap: Map[String, InputStream] = Map()
  try {
    while ( {
      fileIndex < arr.length
    }) {
      if (arr(fileIndex).isFile) {
        inputStream = new FileInputStream(arr(fileIndex))
        inStreamMap = inStreamMap + ("inStream" -> inputStream)
        inStream(count) = inStreamMap
        count += 1

      }

      {
        fileIndex += 1;
        fileIndex - 1
      }
    }

  } catch {
    case e: IOException =>
      e printStackTrace()
  } finally {
    if (inputStream != null)
      try
        inputStream.close
      catch {
        case e: IOException =>
          e.printStackTrace()
      }
  }
  inStream
}
var files = returnFile.listOfFileStreams("src/test/resources/bodies").circular
val scn = scenario("scenario")

  .feed(files)
  .exec(http("request1")
    .post("api")
    .body(InputStreamBody("${inStream}"))
    )

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

val target: WebTarget = ClientBuilder.newBuilder.build
.property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024)
.property(ClientProperties.REQUEST_ENTITY_PROCESSING, “CHUNKED”)
.target(url.toString)

val out = new StreamingOutput() {
  @SuppressWarnings(Array("unused"))
  @throws[IOException]
  @throws[WebApplicationException]
  override def write(output: OutputStream): Unit = {
    try {
      val is = new FileInputStream("hello.wav")
      try {
        var available = 0
        while ( {
          (is.available) > 0
        }) {
          System.err.println("cnt=" + cnt)
          output.write(is.read)
          cnt += 1
        }
      } finally if (is != null) is.close()
    }
  }
}
val response: Response = target.request.post(Entity.text(out))
System.err.println("HTTP status=" + response.getStatus)
System.err.println("response=" + response.readEntity(classOf[String]))