Capture Gatling Traffic through a HTTP Proxy
In this short post, we will see how to redirect our Gatling traffic through a locally running proxy server. Capturing traffic in this way is a great way to debug our scripts. It let’s us see exactly what is being sent by Gatling in the HTTP Requests. We also see everything in the HTTP Response, including the headers.
There are plenty of HTTP proxies to choose from, here are a few of the popular ones:
I’ll be using Fiddler for this post. It’s free, and there are versions available for Mac and Windows.
Download and install Fiddler. It should be straightforward to install, just follow the on-screen prompts. After you launch Fiddler, go to Settings > Connections and check which port Fiddler listens on. I normally set mine to
Now that Fiddler is running, we just need to set the Gatling proxy in our source code.
To set our traffic in Gatling through the Fiddler proxy, we need to add the following to our HTTP configuration:
val httpConf = http.proxy(Proxy("localhost", 8888))
This directs all Gatling traffic to the Fiddler proxy, which is running on
localhost at port
You can optionally set a different port for HTTPS, and supply proxy credentials:
val httpConf = http.proxy(Proxy("myProxyHost", 8888) .httpsPort(8080) .credentials("Username", "Password"))
You can disable the proxy for a given list of hosts with
val httpConf = http.proxy(Proxy("myProxyHost", 8888)) .noProxyFor("www.james-willett.com", "www.gatling.io")
In this short post, we looked at how to direct our Gatling traffic through a HTTP proxy.
For further information on directing Gatling traffic through a Proxy, check the Gatling Documentation.