Gatling proxy configuration

Soumya Simanta picture Soumya Simanta · Sep 10, 2013 · Viewed 11.7k times · Source

This is a followup to this question. I'm using the same configuration. However, I'm trying to use an internal website through a proxy server. I'm not sure if the following the correct way to configure a proxy in the simulation.

 val httpConf = http.proxy("http://proxy.server.address", 8080)

Here is my modified code.

package foo 
import io.gatling.core.Predef._
import io.gatling.core.session.Expression
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import io.gatling.http.Headers.Names._
import io.gatling.http.Headers.Values._
import scala.concurrent.duration._
import bootstrap._
import assertions._

class SimpleSimulation extends Simulation { 
    val httpConf = http.proxy("http://proxy.server.address", 8080)

    val scn = scenario("My scenario")
    .exec(http("My Page")
    .get("http://10.128.3.232:9201/index.html")) 

 setUp(scn.inject(atOnce(50 user))).protocols(httpConf) 

}

I've also modified conf/gatling.conf to include the proxy. I'm not sure what's the correct way to configure the proxy.

http {
        #baseUrls = ""                                                          # default value for the base HTTP URLs
        proxy {
                host = "http://proxy.server.address"                                                               # proxy host (blank means no proxy)
                port = 8080                                                             # HTTP port
                securedPort = -1                                                # HTTPS port (-1 means no HTTPS proxy)
                #username = ""                                                  # proxy username (blank means no credentials)
                #password = ""                                                  # proxy password
        } 

I'm getting the following exception when I run the simulation.

17:09:15.654 [INFO ] i.g.h.a.HttpRequestAction - Sending request 'My Page': scenario 'My scenario', userId #49
17:09:15.655 [WARN ] i.g.h.a.AsyncHandler - Request 'My Page' failed
java.nio.channels.UnresolvedAddressException: null
    at sun.nio.ch.Net.checkAddress(Net.java:36) ~[na:1.6.0_51]
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:512) ~[na:1.6.0_51]
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.connect(NioClientSocketPipelineSink.java:108) ~[netty-3.6.6.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:70) ~[netty-3.6.6.Final.jar:na]
    at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:54) ~[netty-3.6.6.Final.jar:na]
    at org.jboss.netty.handler.codec.http.HttpClientCodec.handleDownstream(HttpClientCodec.java:97) ~[netty-3.6.6.Final.jar:na]
    at org.jboss.netty.handler.stream.ChunkedWriteHandler.handleDownstream(ChunkedWriteHandler.java:109) ~[netty-3.6.6.Final.jar:na]
    at org.jboss.netty.channel.Channels.connect(Channels.java:634) ~[netty-3.6.6.Final.jar:na]
    at org.jboss.netty.channel.AbstractChannel.connect(AbstractChannel.java:207) ~[netty-3.6.6.Final.jar:na]
    at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:229) ~[netty-3.6.6.Final.jar:na]
    at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:182) ~[netty-3.6.6.Final.jar:na]
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1026) [async-http-client-1.7.19.20130706.jar:na]
Wrapped by: java.net.ConnectException: http://10.128.3.232:9201/index.html
    at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:103) ~[async-http-client-1.7.19.20130706.jar:na]
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:427) [netty-3.6.6.Final.jar:na]
    at org.jboss.netty.channel.DefaultChannelFuture.addListener(DefaultChannelFuture.java:145) [netty-3.6.6.Final.jar:na]
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1068) [async-http-client-1.7.19.20130706.jar:na]
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:890) [async-http-client-1.7.19.20130706.jar:na]
    at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:520) [async-http-client-1.7.19.20130706.jar:na]
    at io.gatling.http.ahc.HttpClient$.sendHttpRequest(HttpClient.scala:144) [gatling-http-2.0.0-M3a.jar:na]
    at io.gatling.http.action.HttpRequestAction.io$gatling$http$action$HttpRequestAction$$sendRequest$1(HttpRequestAction.scala:75) [gatling-http-2.0.0-M3a.jar:na]
    at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1$$anonfun$apply$2.apply(HttpRequestAction.scala:84) [gatling-http-2.0.0-M3a.jar:na]
    at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1$$anonfun$apply$2.apply(HttpRequestAction.scala:81) [gatling-http-2.0.0-M3a.jar:na]
    at io.gatling.core.validation.Success.map(Validation.scala:27) [gatling-core-2.0.0-M3a.jar:na]
    at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1.apply(HttpRequestAction.scala:81) [gatling-http-2.0.0-M3a.jar:na]
    at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1.apply(HttpRequestAction.scala:80) [gatling-http-2.0.0-M3a.jar:na]
    at io.gatling.core.validation.Success.flatMap(Validation.scala:28) [gatling-core-2.0.0-M3a.jar:na]
    at io.gatling.http.action.HttpRequestAction.executeOrFail(HttpRequestAction.scala:80) [gatling-http-2.0.0-M3a.jar:na]
    at io.gatling.core.action.Failable$class.execute(Actions.scala:82) [gatling-core-2.0.0-M3a.jar:na]
    at io.gatling.http.action.HttpRequestAction.execute(HttpRequestAction.scala:54) [gatling-http-2.0.0-M3a.jar:na]
    at io.gatling.core.action.Action$$anonfun$receive$1.applyOrElse(Actions.scala:42) [gatling-core-2.0.0-M3a.jar:na]
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:166) [scala-library-2.10.2.jar:na]
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425) [akka-actor_2.10-2.1.4.jar:na]
    at akka.actor.ActorCell.invoke(ActorCell.scala:386) [akka-actor_2.10-2.1.4.jar:na]
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230) [akka-actor_2.10-2.1.4.jar:na]
    at akka.dispatch.Mailbox.run(Mailbox.scala:212) [akka-actor_2.10-2.1.4.jar:na]
    at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:506) [akka-actor_2.10-2.1.4.jar:na]
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.10.2.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.10.2.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.10.2.jar:na]
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.10.2.jar:na]
17:09:15.656 [WARN ] i.g.h.a.AsyncHandlerActor - Request 'My Page' failed : http://10.128.3.232:9201/emontage/home.html
17:09:15.656 [DEBUG] i.g.h.a.AsyncHandlerActor - 
>>>>>>>>>>>>>>>>>>>>>>>>>>
Request:
My Page: KO http://10.128.3.232:9201/index.html
=========================
Session:
Session(My scenario,49,Map(),1378847355391,0,List(),List(KO),List(),List())
=========================
HTTP request:
GET http://10.128.3.232:9201/index.html
=========================
HTTP response:

<<<<<<<<<<<<<<<<<<<<<<<<<

Answer

Jordan Glue picture Jordan Glue · Oct 15, 2015

This has changed since 2013 when the question was originally answered. Their documentation link has changed, and the function definition for proxy has changed to be:

val httpConf = http.proxy(Proxy("myProxyHost", 8080))