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.



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

  1. SudhakarReddy

    i am unable to record Apps getting error like as Connection Error : “please make sure you are using the latest version of the app”. i did same what you said. Can you help me.

    1. SudhakarReddy

      even i downloaded latest app also getting same error

  2. Malo Zollikofer

    Hey,

    Thanks for this tuto !
    I’m actually facing a problem that you may know how to resolve..
    I want to do this with in SSL app, so I did everything with the certificate.
    What’s happening now is this error:

    2018-02-27 14:39:50,200 INFO o.a.j.p.h.p.ProxyControl: [61687] Creating entry xxx.118-xxx.ch in C:\xxx\apache-jmeter-4.0\bin\proxyserver.jks
    2018-02-27 14:39:50,717 ERROR o.a.j.p.h.p.Proxy: [61687]  Problem with keystore
    java.io.IOException: >> erreur keytool : java.lang.RuntimeException: java.io.IOException: DNSName components must begin with a letter <<
    Command failed, code: 1
    'keytool -genkeypair -alias xxx.118-xxx.ch -dname "cn=xxx.118-xxx.ch, o=JMeter Proxy (TEMPORARY TRUST ONLY)" -keyalg RSA -keystore proxyserver.jks -storepass {redacted} -keypass {redacted} -validity 7 -ext san=xxx.118-xxx.ch'
    at org.apache.jorphan.exec.KeyToolUtils.genkeypair(KeyToolUtils.java:171) ~[jorphan.jar:4.0 r1823414]
    at org.apache.jorphan.exec.KeyToolUtils.generateSignedCert(KeyToolUtils.java:285) ~[jorphan.jar:4.0 r1823414]
    at org.apache.jorphan.exec.KeyToolUtils.generateHostCert(KeyToolUtils.java:276) ~[jorphan.jar:4.0 r1823414]
    at org.apache.jmeter.protocol.http.proxy.ProxyControl.updateKeyStore(ProxyControl.java:1563) ~[ApacheJMeter_http.jar:4.0 r1823414]
    at org.apache.jmeter.protocol.http.proxy.Proxy.getSSLSocketFactory(Proxy.java:324) [ApacheJMeter_http.jar:4.0 r1823414]
    at org.apache.jmeter.protocol.http.proxy.Proxy.startSSL(Proxy.java:429) [ApacheJMeter_http.jar:4.0 r1823414]
    at org.apache.jmeter.protocol.http.proxy.Proxy.run(Proxy.java:194) [ApacheJMeter_http.jar:4.0 r1823414]
    2018-02-27 14:39:50,717 WARN o.a.j.p.h.p.Proxy: [61687] Unable to negotiate SSL transaction, no keystore?
    2018-02-27 14:39:50,717 ERROR o.a.j.p.h.p.Proxy: [61687]  Exception when processing sample
    java.io.IOException: Unable to negotiate SSL transaction, no keystore?

    As you can see, I'm using a domain name starting with number. It looks like keytool cannot handle that.

    Best,

    Mz

  3. Ritesh Bilgaiyan

    Hii,

    I am currently working on Performance Testing of Native app. I tried with proxy, disabled the firewall, installing the ROOT CA certificate but still not recording is happening. But if i tried to record with browser on mobile then scripts will get record on JMeter.
    Can you help me on this issue ?

    1. Jaya

      Facing the same issue.
      I am currently working on Performance Testing of Native app. I tried with proxy, disabled the firewall, installed ROOT CA certificate but still not recording is happening. But if i tried to record with browser on mobile then scripts will get record on JMeter.

      Can anyone help me in sorting out this issue soon?

  4. Poornachandra M R

    I did all settings as show above.
    I’m in office inside proxy settings.
    If i set system IP in firefox settings, i’m not able to even open Google in browser.
    I tried passing proxy IP from command prompt, it didn’t work.

    If i give Proxy address in firefox settings it won’t get recorded in Jmeter at all.
    Please help…

    1. Alagappan

      Hi Poornachandra,

      Did you install “ApacheJMeterTemporaryRootCA.crt” certificate on your device?
      Check that certificate have a validity (7 days). If not, regenerate that and install again on your device.
      Don’t use to test public application/websites because it has been secured with SSL.(Eg: Google,Whatsapp,etc.)
      Recommended to record Non-secured app/websites in browser which means the application have not secured with SSL certificate.
      Jmeter server and your office network port should be different. If it has a same port, wont work at all.
      Wifi and Port should be same on your device and system.
      Try different wifi network which has not connect with proxy settings.

      Thanks for your feedback.
      Email me at: alagappanmca21@gmail.com. if anything else.

  5. Poornachandra

    I have done all setup properly, but still i’m not able to record script. Please help

  6. TrainingRite

    Hey,
    Well explained!! Really useful. Keep posting and let us know the new ideas and techniques!!

    :) Thank you

  7. anshu

    Hi,

    I am trying to record script of one office app, but in my personal laptop/network. I followed all steps and i was able to record script. After 2 days i tried again , my app sopped working on changing proxy and now it started showing check your internet connection message as well. Kindly let me know , if you have any solution to this. According to my knowledge, when i was able to record after that I didn’t change any settings, but still not able to record. My internet stop working after changing proxy. Waiting for response.

    1. Alagappan

      Hi Anshu,

      Sure i will help you.

      First, i should recommend you to test Non-secure app which means the app shouldn’t deployed with SSL certificate.If you want to test your own secured product, you may need to install SSL certificate on your device.
      For more information to install certificate on android, go through this: https://cheapsslsecurity.com/blog/install-ssl-certificate-on-android/
      For iOS: https://support.quovadisglobal.com/kb/a64/how-do-i-install-a-digital-certificate-onto-an-iphone-or-ipad.aspx.

      And then ensure to check the following settings has been done on your device and jmeter/laptop.

      1.The Wifi network and port should be same in both device and jmeter.
      2.Device should have installed “ApacheJMeterTemporaryRootCA.crt” certificate. This certificate has 7 days validity period from the date of generated,after that it will expired. you should need to re-generate from jmeter and use it on your device.
      3. Turn off the firewall protection on your windows firewall and antivirus software,their might be restrict your proxy connection.
      4.If your office internet has proxy, you should open the jmeter.bat file behind a proxy (if it has been changed, use that changed proxy to restart your jmeter).

      Note: Secured applications/websites and mobile apps wouldn’t work without those JmeterRootCA and SSL certificates. Don’t use other companies products for performance test in jmeter (eg: Google products,facebook,whatsapp,etc.). Test your own products developed by you or your company.

      Hope it will help you.If you need anything else mail me at alagappan.n@vmokshagroup.com

  8. 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

  9. 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.

  10. 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.

      1. Omkar

        Dear Alagappan,
        Internet is not working with Proxy on the mobile device when we configure the mobile device and JMeter.
        I have done all the settings, mentioned but i’m unable to record anything and I get net::ERR_PROXY_CONNECTION_FAILED error when I click on any webpage or app.
        Also i could not understand the steps you mentioned above-

        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.

        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. —> What exactly should I do??? My IP is set to 172.20.188.60 & port is set to 8888 by default.
        Do I have to type 172.20.188.60:8888 in the browser to verify?

        Then we have to follow the below steps:
        Open apache-jmeter folder from the local drive and go to the bin folder.
        Open “jmeter (.properties)” file and find “Remote hosts and RMI configuration” section on this file.
        Under this section, add the system IP to remote hosts with comma delimited and save the file. —> Here again should i replace the 127.0.0.1 with my IP address??
        Please guide me…also In our office, we don’t have a proxy to access internet, its direct.

        In web browser i have set the settings to HTTP Proxy -> localhost & port 8888

        I’m unable to proceed further, kindly help.

        Regards,
        Omkar
        9920714477

  11. 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?

    2. Kate Wilson

      It will show the actions once you are done performing the steps and then stop the recorder and click on run, then expand the ‘Recording Controller’. All APIs will appear there.

  12. 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

  13. Sagar Sheth

    Good job buddy!!!

  14. 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 to Alagappan Cancel 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>