java.nio.channels.ClosedChannelException: null error in Gatling

Hi Team,

I am using Gatling 3.0.2 and 3.0.3. While executing the Gatling script , I am getting the below error:

Simulation RecordedSimulation started…
23:30:17.921 [WARN ] i.g.h.e.GatlingHttpListener - Request ‘request_0’ failed for user 1
java.nio.channels.ClosedChannelException: null
at io.netty.handler.ssl.SslHandler.channelInactive(…)(Unknown Source)
23:30:17.939 [WARN ] i.g.h.e.r.DefaultStatsProcessor - Request ‘request_0’ failed for user 1: j.n.c.ClosedChannelException

Please provide a way for us to reproduce on our side.

The application is internal. So could not be accessed outside. But if you could please let me know the scenarios in which this error comes then that would be good.

Hi Team,

I am using Gatling 2.3.1 and trying to set value in session as below, but when i print session Key & Value i have set is not being updated in session and when i am trying to get the value from session it not there.

My code is below,

.exec { session =>
  var AuthCodeFullString = session("gatling.http.referer").as[String]
  session.set("AuthCode",AuthCodeFullString.split("=")(1).split("&")(0))
  println("AuthCode = "+ session("AuthCode").as[String])
  println(session)
  session
}

Please some one can help me what’s wrong in code?

session is immutable. You function literal should be returning the session object returned by session.set:

.exec { session =>
  var AuthCodeFullString = session("gatling.http.referer").as[String]
  val s1 = session.set("AuthCode",AuthCodeFullString.split("=")(1).split("&")(0))
  println("AuthCode = "+ s1("AuthCode").as[String])
  println(s1)
  s1
}

Note you really shouldn’t use Gatling’s internals.
Use a check with currentLocation instead of hacking the way we currently handle the referer.

Hi Slandelle,

Thanks for responding, this help a lot.

I never had intention to hack gatling internal but could not find other way,

actually i am trying to do what, one of my request will come back with response header something like below,

HTTP response:### status=### 302 Found### headers=### Content-Language: en-US### clientCorrelationId:### Location: http://www-perf.target.com/?code=R_YTQXp7xs5MXtJs7BNtMuxrjdW0M_HJAn1oGcfhOD_Op7fYXT-fNHdLIfLAG1g2Z3ozw1EItE90ylw2v41Sy7sDCqtjdGEh716I4UDFSnf9k6OCuY1FC8EQVRAbw8PZvJ4c47OmCv-OFINXvoxvUjOzDMMUNR-rGoqTgyTAWB3R4fMD7ygb5e06tZbmRhATUg4LTkbyvLSH52H7e9qrxroYQaj1Z6YIe6JgksphVW8pG6jP9Zt0zvZUUgRPL_eWxuyAZ5pBIDbusKB1P8ykAw_7tO2aVxFe-XAYHCY5WvL_-qk4txoSv4NjvUVcHmNgp8MHS7wKHlNpnuJTxYzEi_KJnlLKNYV54Q1hU8eGnQjAABG02t4m4roYm3KN8iaSUiNvjnFqj3Db0NyrHD4syHkoot7-yobgLKhWzlmJaDdt9IV-SJ3KrftPUfYI7FNQRP9V7rgtcEX_oOZ_o7kY_oWk2ao-dFnC8Wnw4ga3vWMutYlizJrlgUSwxcchDqwj5Rn4R63II5RxEHOLQKyCRUw2NufNHULnSCO-VggmoVTIMu_0WwzT40zmhAKVY6yN&state=1534868996011&status=success### l5d-success-class: 1.0### Expires: 0

I want to capture “Location” response header value but could not find proper regex and value. when I printed session value i got the internal used name referer so used it.
do you have some solution for the same?

This question comes over and over again, maybe because that’s the only way with other tools.
So I’ll have to write it in capital and bold so maybe other people who would stumble on this thread will get it right:

DO NOT TRY TO CAPTURE LOCATION HEADER FROM REDIRECTED REQUESTS!!!
USE currentLocation AND currentLocationRegex CHECKS TO CAPTURE DATA FROM THE LANDING URL (WHICH IS EQUAL TO LOCATION).
SEE DOCUMENTATION: https://gatling.io/docs/current/http/http_check/?highlight=currentlocation#page-location

Hope it helps…