Request timeout to localhost

Hi guys, I am using Gatling since 2 weeks and it is kinda interesting because it timeouts my requests to my localhost after all I am doing pretty simply scenario.

package placeBet

import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._

class placeBet extends Simulation {

// List of environments
val environments: Map[String, String] =
Map(
“localhost” → “http://localhost
)

// List of user token
val tokens: Array[String] =
Array(
// CustomerId = 123
“Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJQbGF5ZXJJZCI6IjEyMyIsIlNlc3Npb25JZCI6IjQ0YzE4ZmFjLTY1NWUtNGZhZi04OTY3LTE0ZDc5ZDEyYzk0NCIsIlNpdGVJZCI6IjEiLCJuYmYiOjE1MTY5MDMwNjIsImV4cCI6MTUxNzUwNzg2MiwiaWF0IjoxNTE2OTAzMDYyfQ.GjLa9lf_l1HD4bYyOKXxkGiJ_Sv-Z5dhw-L91JRMv4E”
)

val environment = (environments get “localhost”).getOrElse("")

// First HTTP protocol with first token
val httpProtocol = http
.baseURL(environment)
.inferHtmlResources()
.headers(
Map(
“Accept” → “/”,
“Authorization” → tokens(0),
“ContentType” → “application/json”
)
)

val headers = Map(
“accept-encoding” → “gzip, deflate”,
“cache-control” → “no-cache”,
“content-length” → “242”)

// First scenario - place bet ← currently it is set up for dev/local
val scn = scenario(“placeBet”)
.exec(http(“request_1”)
.post("/betting/placeBets")
.headers(headers))

setUp(
scn.inject(
atOnceUsers(5)
).protocols(httpProtocol)
)
}

Sometimes it works sometimes not…

Can you help me? I already increased request timeout configuration with no luck.

Sometimes it works somethimes not suggest that theres something wrong with your service rather than gatling, try hitting it manually using curl or postman with same request…