Network traffic capturing

Mobitru provides functionality for capturing HTTP(s) request data on a real Device during an App or Web session.
It means, you can record and download the HTTP traffic data in HAR file format.
The capturing can be started or stopped anytime during the Session, but it is available for Android devices only.

Run the HTTP traffic capturing

The data capturing can be started any time after taking a Device and starting a Session.
This can be performed before or after manual interactions or executing tests.

Prerequisites

It’s required to have a user certificates validation in the Android Apps.
The validation can be configured in multiple ways and it’s necessary to avoid issues with insecure certificate errors.
More information can be found here.
Here is an example of a base config part:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:tools="http://schemas.android.com/tools">
    <base-config cleartextTrafficPermitted="true"
        tools:ignore="InsecureBaseConfiguration">
        <trust-anchors>
            <certificates src="system" />
            <certificates src="user"
                tools:ignore="AcceptsUserCertificates" />
        </trust-anchors>
    </base-config>
</network-security-config>

Step 1: Start recording

For now, it can be performed only via REST API and only requires the device’s UDID.
In addition, it’s possible to enable capturing of response content and binary data.
Here is an example cURL request to start:

curl --location 'https://app.mobitru.com/billing/unit/<BILLING_UNIT>/automation/api/device/<DEVICE_UDID>/har' \
--header 'Authorization: Bearer <ACCESS_KEY>' \
--header 'Content-Type: application/json' \
--data '{
    "captureResponseContent": true
}'

As a result, you will receive a HAR file id:

{
    "harId": "b02047f3-c0d5-4a63-93c3-6a82cbf22ab9"
}

Step 2: Stop recording

You can stop the Captring by another REST API, which, also, requires the device UDID.
Here is an example cURL request to stop:

curl --location --request DELETE 'https://app.mobitru.com/billing/unit/<BILLING_UNIT>/automation/api/device/<DEVICE_UDID>/har' \
--header 'Authorization: Bearer <ACCESS_KEY>' \
--header 'Content-Type: application/json'

As a result, you will again receive the HAR file id:

{
    "harId": "b02047f3-c0d5-4a63-93c3-6a82cbf22ab9"
}

Step 3: Download HAR

The result in HAR file format can be downloaded by another REST API, which requires the HAR file id.
Here is an example cURL request to download:

curl --location 'https://app.mobitru.com/billing/unit/<BILLING_UNIT>/automation/api/har/<HAR_FILE_ID>' \
--header 'Authorization: Bearer <ACCESS_KEY>' \
--header 'Content-Type: application/json'

As a result, you will again receive the HAR file content in JSON format:

{
    "log": {
        "comment": "",
        "creator": {
            "comment": "",
            "name": "BrowserMob Proxy",
            "version": "2.1.5"
        },
        "version": "1.2",
        "pages": [
            {
                "comment": "",
                "id": "Page 0",
                "pageTimings": {
                    "comment": "",
                    "onLoad": 54978
                },
                "startedDateTime": "2024-04-26T18:59:10.588Z",
                "title": "Page 0"
            }
        ],
        "entries": [
            {
                "cache": {},
                "comment": "",
                "pageref": "Page 0",
                "request": {
                    "bodySize": 0,
                    "comment": "",
                    "cookies": [],
                    "headers": [
                        {
                            "name": "Host",
                            "value": "detectportal.firefox.com"
                        },
                        {
                            "name": "User-Agent",
                            "value": "Mozilla/5.0 (Android 12; Mobile; rv:109.0) Gecko/114.0 Firefox/114.0"
                        },
                        {
                            "name": "Accept",
                            "value": "*/*"
                        },
                        {
                            "name": "Accept-Language",
                            "value": "en-US"
                        },
                        {
                            "name": "Accept-Encoding",
                            "value": "gzip, deflate"
                        },
                        {
                            "name": "Connection",
                            "value": "keep-alive"
                        },
                        {
                            "name": "Pragma",
                            "value": "no-cache"
                        },
                        {
                            "name": "Cache-Control",
                            "value": "no-cache"
                        }
                    ],
                    "headersSize": 317,
                    "httpVersion": "HTTP/1.1",
                    "method": "GET",
                    "queryString": [
                        {
                            "name": "ipv6",
                            "value": ""
                        }
                    ],
                    "url": "http://detectportal.firefox.com/success.txt?ipv6"
                },
                "response": {
                    "bodySize": -1,
                    "comment": "",
                    "content": {
                        "comment": "",
                        "mimeType": "",
                        "size": 0
                    },
                    "cookies": [],
                    "headers": [],
                    "headersSize": -1,
                    "httpVersion": "unknown",
                    "redirectURL": "",
                    "status": 0,
                    "statusText": "",
                    "_error": "No response received"
                },
                "startedDateTime": "2024-04-26T18:59:18.159Z",
                "timings": {
                    "comment": "",
                    "blocked": 0,
                    "connect": -1,
                    "dns": -1,
                    "receive": 0,
                    "send": 0,
                    "ssl": -1,
                    "wait": 0
                },
                "time": 0
            },
            {
                "cache": {},
                "comment": "",
                "pageref": "Page 0",
                "request": {
                    "bodySize": 0,
                    "comment": "",
                    "cookies": [],
                    "headers": [
                        {
                            "name": "Host",
                            "value": "detectportal.firefox.com"
                        },
                        {
                            "name": "User-Agent",
                            "value": "Mozilla/5.0 (Android 12; Mobile; rv:109.0) Gecko/114.0 Firefox/114.0"
                        },
                        {
                            "name": "Accept",
                            "value": "*/*"
                        },
                        {
                            "name": "Accept-Language",
                            "value": "en-US"
                        },
                        {
                            "name": "Accept-Encoding",
                            "value": "gzip, deflate"
                        },
                        {
                            "name": "Connection",
                            "value": "keep-alive"
                        },
                        {
                            "name": "Pragma",
                            "value": "no-cache"
                        },
                        {
                            "name": "Cache-Control",
                            "value": "no-cache"
                        }
                    ],
                    "headersSize": 317,
                    "httpVersion": "HTTP/1.1",
                    "method": "GET",
                    "queryString": [
                        {
                            "name": "ipv4",
                            "value": ""
                        }
                    ],
                    "url": "http://detectportal.firefox.com/success.txt?ipv4"
                },
                "response": {
                    "bodySize": 8,
                    "comment": "",
                    "content": {
                        "comment": "",
                        "mimeType": "text/plain",
                        "size": 8,
                        "text": "success\n"
                    },
                    "cookies": [],
                    "headers": [
                        {
                            "name": "Server",
                            "value": "nginx"
                        },
                        {
                            "name": "Content-Length",
                            "value": "8"
                        },
                        {
                            "name": "Via",
                            "value": "1.1 google"
                        },
                        {
                            "name": "Date",
                            "value": "Fri, 26 Apr 2024 09:22:21 GMT"
                        },
                        {
                            "name": "Age",
                            "value": "34616"
                        },
                        {
                            "name": "Content-Type",
                            "value": "text/plain"
                        },
                        {
                            "name": "Cache-Control",
                            "value": "public,must-revalidate,max-age=0,s-maxage=3600"
                        }
                    ],
                    "headersSize": 210,
                    "httpVersion": "HTTP/1.1",
                    "redirectURL": "",
                    "status": 200,
                    "statusText": "OK"
                },
                "serverIPAddress": "34.107.221.82",
                "startedDateTime": "2024-04-26T18:59:18.192Z",
                "timings": {
                    "comment": "",
                    "blocked": 0,
                    "connect": 23,
                    "dns": 35,
                    "receive": 14,
                    "send": 3,
                    "ssl": -1,
                    "wait": 14
                },
                "time": 91
            },
            ...
        ]
    }
}
Limitations
  • Max HAR file size is 500MB and any exceeded data will be not recorded
  • The Capturing is not available when the Local tunneling is started
  • The retention time for a HAR file is 1 hour
Scroll to Top