How to Test Native App Performance using Apache JMeter?

In my previous blog, I have elucidated how to test web application’s performance using JMeter. Here, I would like to share how to test mobile app’s performance in JMeter.

JMeter records mobile application requests on HTTP(S) Script Recorder and it has features to prepare and run our mobile application performance test scripts. All we have to do is to configure JMeter and Mobile device. In JMeter, we can test both iOS and Android native applications.

Steps to Configure JMeter:

  1. Go to apache-jmeter-3.1/bin folder and start the jmeter.bat (Batch) file.
  2. Right click on “Test Plan” > Add > Threads User(s) > Thread Group.
  3. Right click on “Thread Group” > Add > Logic Controller > Recording Controller.
  4. Right click on “Thread Group” > Add > Listeners > View Results in Tree.
  5. Add HTTP(s) Script Recorder to Workbench by selecting Workbench > Add > Non-Test Elements > HTTP(s) Script Recorder option.
  6. Add Port value as 8080 and click “START” button in script recorder. The JMeter proxy will be started on localhost.

Note: If you are testing from behind a firewall/proxy server, you may need to run the jmeter.bat file from a command line mode to use following parameters (If you are working under proxy network in office, use this method.)

Go to jmeter/bin directory and enter this:

jmeter.bat -H <Hostname or ip address> -P <Server port> -N <Non proxy hosts> -u <Username for proxy – If required> -a <Password for proxy – if required>

Example: jmeter.bat -H my.proxy.server -P 9090  -u username -a password -N localhost

Next, we need to configure the mobile device as per the following steps.

Before starting the configuration on your device, you should install “ApacheJmeterTemporaryRootCA.crt” certificate in your mobile/tab device.

Steps to install the certificate:

1. Go to jmeter/bin directory and find the ApacheJmeterTemporaryRootCA.crt file. (If you cannot find the certificate from bin directory, just go to your HTTP(S) script recorder screen in Jmeter and click ‘Start’ button. It will generate new certificate on your bin directory automatically).

2. Attach that file and send an email to yourself.

3. Download from your mail and then install on your device.

After installing successfully, you will see the notification “Network may be mounted” on android device. Here you can verify whether the certificate has been installed. For iOS device, it will show you the “Profile Installed” pop-up and you can see the ‘Verified’ sign. Tap ‘Done’ at the top right corner to complete the installation.

Note: Ensure to check whether the certificate has been expired or not. Certificate will be expired within 7 days from the date of generated. If it has expired, simply re-generate again and use it.

iOS Device Proxy Configuration:

  1. Go to Settings > Wi-Fi option. (Note: Network should be same for both Mobile and Laptop/Desktop).
  2. Click on the Connected network.
  3. Select “Manual” option from HTTP Proxy.
  4. Set ‘Server value as system IP address and Port value to 8080 as per JMeter setup.
  5. Now start the application on the device and its each request will be recorded in JMeter.

 Android Jmeter

Android Device Proxy Configuration:

#1. Go to Settings > Wi-Fi option.

#2. Press and hold on connected network and Click ‘Modify Network’ option.

#3. This will open advanced settings from where we can modify Proxy.

#4. Change the Proxy to Manual.

Apache JMeter

#5. Set Hostname value as system IP address and Port value to 8080 as per JMeter setup.

Android PAC

#6. Click on ‘Save’.

#7. Now start the application on the device and its each request will be recorded in JMeter.

#8. Before running the application, make sure that HTTP(S) script recorder was started in JMeter.

#9. Once the application is started, the actions of the script will be recorded under “Recording Controller.”

#10. Once actions are done in the application, stop the script recording by clicking ‘Stop’ button in HTTP(S) script recorder screen.

#11. Now, expand the “Recording Controller” in JMeter. You can view all the Recorded scripts of whatever actions are done in the applications.

#12. Finally, click the ‘Play’ button. It will run recorded scripts as per your Threads setup.

#13. Click on “View Results in Tree”. Here you will see the result of your script.

 

Solutions for issues while testing the mobile application:

Here are the solutions for the issues that we have noticed while doing the load test in JMeter.

Issue 1

The application wasn’t getting loaded.

Solution

The issue is caused because our system was enabled with the firewall protection in security software. This is restricting network connection when setup with the proxy. We have disabled the firewall protection in antivirus settings.

Issue 2

Internet was not working with Proxy on the mobile device when we configure the mobile device and JMeter.

Solution

The reason might be that the system IP address is not configured with JMeter properties which mean the current IP address is not added to the JMeter properties file. We have added remote host IP address to property file as per the following steps.

  1. Open the browser and type IP address and Port number that is mentioned in JMeter to check whether it was configured. If browser shows Connect, then it is working fine otherwise if it is continuously loading, then it was not configured. Then we have to follow the below steps:
  2. Open apache-jmeter folder from the local drive and go to the bin folder.
  3. Open “jmeter (.properties)” file and find “Remote hosts and RMI configuration” section on this file.
  4. Under this section, add the system IP to remote hosts with comma delimited and save the file.
FacebookTwitterGoogle+Share
About Alagappan Narayanan

Alagappan Narayanan is an Associate software engineer at Vmoksha Technologies. He is passionate about exploring new automation technologies for mobile and web application testing. He loves reading novels, traveling, and trekking. He has done Master's in Computer Application at Bharathidasan University.



11 comments on “How to Test Native App Performance using Apache JMeter?

  1. vidhya

    i am trying to test native mobile app api using jmeter .But i am getting this error

    javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:992)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
    at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:928)
    at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
    at org.apache.jmeter.protocol.http.proxy.HttpRequestHdr.parse(HttpRequestHdr.java:118)
    at org.apache.jmeter.protocol.http.proxy.Proxy.run(Proxy.java:210)
    Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at sun.security.ssl.InputRecord.read(InputRecord.java:505)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
    … 7 more

    kindly assist me to overcome this

  2. Brooks

    Hi Narayanan,

    Kudos to your work. However, I need some more assistance from your end. I have followed all the steps whatever you described there but still am getting the error message “No Internet connectivity” Can you please respond with your inputs at the earliest with the root cause.

    Note: I have followed the given solutions as well but no use and I got the same result.

  3. Viji Chandramohan

    Hi,

    I am trying to record a native app in my android tab. Even after doing all these setting, my script is not getting recorded, can you please help? In my office, we don’t have a proxy to access internet, its direct.

    Regards,
    Viji…

    1. Alagappan

      Hi Viji.
      Thanks for raising query.

      If you have to access the jmeter at your office network, you should be open the Jmeter.bat file from command line after that you will do all these setting.

      Use below command to open the jmeter:

      Open command prompt and type this: jmeter.bat

      If your internet have a proxy, Use this behind proxy command to open jmeter:

      jmeter.bat -H -P -N

      At any case, always to open the jmeter.bat file from command prompt for recording script (GUI mode) and for load testing recommand you to use Non-GUI mode.

      Please ensure the following setup were done properly after that start the testing on your app:

      1.Your Wi-fi network should be same in both Laptop/Desktop and Mobile/Tab device.
      2.The “ApacheJMeterTemporaryRootCA” cerficate should be installed on your device.
      If your device dont have this cerficate, downlaod that from https://gist.github.com/borisguery/9ef114c53b83e553b635 and send that file through mail then install on your device.
      3.Firewall protection should be disabled in Laptop/Desktop.
      4.Port number should be same in Jmeter and Device.

      After these, still you will not getting recorded. Please let me contact (alagappanmca21@gmail.com). I will help you.

  4. Parthasarathy

    Hi,

    I try to start HTTP(s) script recorder but not able to make it. Its not starting

    1. Alagappan

      Please let me know what happen on click the ‘Start’ in HTTP(s) script recorder screen?
      Does the jmeter has been creating the RootCACertificate when start?
      What are the configure steps you did before start?

  5. Ashwani

    HI , Is it possible to pull the script from Jmeter so that i can also automate the native android app via Appium or any other Automation tool.

    1. Alagappan

      Yes. you can pull the scripts and save that script as different formats like CSV,JMX,etc.
      You can upload that script file to online tools and get detail report. But am not sure about to automate that scripts via appium tool and other automation tools.

      Online Tools:

      Blaze meter -> https://www.blazemeter.com
      Redline13 -> https://www.redline13.com

  6. Sagar Sheth

    Good job buddy!!!

  7. Ram Lakshmanan

    Until I read this article, I didn’t know that Apache JMeter can be used for native app load testing. Good eye opener.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>