SSH own protocol


I’m developing my own gatling protocol. The protocol is based in ssh connections. To do this I use java libraries to connect every virtual user to the server, but I have a problem: I want to mantain an ssh connection opened between interactions (first connect and after that several command executions).

I defined two actions:

package protocol

class Upper(requestName: String) {
def connect() = new UpperConnectActionBuilder(requestName)
def ejecutar(comando:String) = new UpperExecuteActionBuilder(requestName,comando)
//def disconnect() = new UpperDisconnectActionBuilder(requestName + “otroconnect”)

The connection is opened when we execute connect(), so I need to store that connection in the session:

class UpperConnect(protocol: UpperProtocol, val statsEngine: StatsEngine, val next: Action) extends ExitableAction with NameGen {
override def name: String = genName(“upperConnect”)

override def execute(session: Session) = {
val ssh = new ClienteSsh(, protocol.port,protocol.user,protocol.password,protocol.timeout)
val start = System.currentTimeMillis


val end = System.currentTimeMillis

println(“Mi sesion ----->” + session.attributes)

session.set(“clientesshstring”, “ssh”)
session.set(“clientessh”, ssh)
println(“Mi sesion ----->” + session.attributes)
val timings = ResponseTimings(start, end)
statsEngine.logResponse(session, name, timings, OK, None, None)
next ! session

But I can’t see the object stored in the session. What do I have to do to save that object?