Modern network applications use REST, which is de facto the standard in today's development for both web and mobile applications. REST (Representational State Transfer) is an architecture of web applications that describes the backend as a state that can be fetched or modified through requests sent to a collection of endpoints (POST, PUT, GET) that accept and return objects in JSON format.
When debugging web applications, there is often a need to analyze REST requests. Sometimes logs in the application are insufficient or impossible to obtain. Then there is a need for a tool that will enable analyzing network traffic without interfering with the application itself. To achieve this, we can use Wireshark.
In this article, I will show how to use Wireshark to log and analyze network traffic between the backend and frontend parts of the application.
To install Wireshark, it is best to use the official instructions or the repository available for your operating system. Click here to go to the official download page.
Additionally, we will create a simple web application that will expose a simple
REST endpoint. For this purpose, we will use the express.js framework, which
is one of the most popular frameworks for creating web applications in Node.js.
To do this, use the following code (paste into app.js
in a new folder):
const express = require("express");
const app = express();
const port = 3000;
app.get("/api", (req, res) => {
res.json({ message: "Hello World!" });
});
app.listen(port, () => {
console.log(`Listening at http://localhost:${port}`);
});
To run the application, you will need node.js and to install dependencies using
npm. To run the application, use the following commands (before starting, make
sure you have installed node.js and are in the folder with the app.js
file):
npm init -y
npm install express
node app.js
To test the operation of the application, open a browser and enter the address
http://localhost:3000/api
. The response should be
{"message":"Hello World!"}
.
Then start Wireshark and select the correct interface. If you do not know which
interface to choose, use the any
option, which allows listening to all network
interfaces.
It should be noted that Wireshark requires administrator rights to listen to network traffic on all interfaces. If you suspect that Wireshark is not working correctly, check the permissions. For example, in Linux, you can run Wireshark with root permissions using the following command:
sudo wireshark
After performing these steps, Wireshark will start logging all network traffic passing through the selected network interface. Usually, the amount of logged data is very large, as Wireshark by default logs all network packets. To see only the HTTP requests that interest us, it is necessary to set up appropriate filters.
The most important filters for our case are:
http
- filters all HTTP requestsip.src
- filters requests sent from a specific IP addressip.dst
- filters requests sent to a specific IP addressTo filter the logged data, add the appropriate expression in the filter bar at
the top of the interface. For example, to see all packets sent to the IP address
localhost, enter: ip.dst = 127.0.0.1
, to see all HTTP requests sent or
received by the application running on localhost, enter:
(ip.dst = 127.0.0.1 or ip.src = 127.0.0.1 and http)
.
Localhost (127.0.0.1) is the IP address assigned to the network interface loopback, which is used for communication between processes on the same device. In the case of a web application running on a local server, HTTP requests will be sent to this IP address.
Now Wireshark displays only the incoming and outgoing traffic of our application. After refreshing the page in the browser, new HTTP requests should appear. In the example below, the first two requests are respectively the request to and response from our application.
It is also worth knowing how to see the payload of requests in JSON format. By default, Wireshark allows the analysis of request payloads in an unintuitive, native format. To obtain the data in a more readable format, use the "copy as printable text" function available in the menu, under the right mouse button in the section displaying the body of the request.
To obtain the body of the request in JSON format, select the appropriate request
and Java Script Object Notation
and then use the option
copy as printable text
.
To obtain the header of the request, select the appropriate request and
Hypertext Transfer Protocol
, and then use the option copy as printable text
.
I have discussed the key aspects of using the Wireshark tool for debugging web applications, focusing on REST requests, which are the basis of modern internet and mobile applications. Wireshark, as an advanced tool for analyzing network traffic, allows observing HTTP requests without the need to interfere with the application code. Properly configured filters allow tailoring Wireshark's operation to our needs.
At Blues Brackets we solve real business challenges with the latest and proven technology.
React Development Services
Custom Embedded Software Development Services
Mobile App Development Services
Professional Arduino Development
Expert RTOS Development Services
MVP Development Services | Custom MVP Development Company
Agile Software Development Services
Flutter App Development Services
Proof of Concept & Proof of Principle Services
Cross-Platform Mobile Development
Software House Poland | Custom Web & Embedded Solutions
IT Staff Augmentation Services in Poland
PWA Development Services | iOS & Android
Animated Website Services. Design and Implementation
UX/UI Design Services. Project and Implementation
Expert Hardware Design Company | Custom Electronic Hardware
Remote IT Support & App Maintenance – bluesBrackets
EAA Accessibility & Compliance Software Development
Software Maintenance & Legacy Services | bluesBrackets
Hire Dedicated Development Teams in Poland – bluesBrackets
Business Intelligence Solutions | bluesBrackets
Data Engineering & Data Visualization Services
IoT Development Services | Custom IoT Devices & Solutions
AI Chatbot Development Services
Next.js & WordPress Services
Custom Web App Development Services
DevOps Consulting Company | bluesBrackets
DevOps as a Service | AWS Cloud Consulting
SaaS Software Development Company: GDPR-Compliant Cloud
NB-IoT Solutions & Agile Development
Microservices vs Monolithic: Expert Software Architecture
IoT & Smart City Software Development | bluesBrackets
IoT Product Development & Custom Software Solutions
SLA-Driven Software & Managed Services Poland
Industrial IoT & Industry 4.0 Software Solutions
Outsource Python Development | Offshore Company
Energy Storage & IoT Software Solutions
IoT Device Management Platform & Custom IoT Solutions
Backend Services & JavaScript Development | bluesBrackets
Travel Software Development Company | Custom Travel Apps
IoT & Wearable Tech Development | bluesBrackets
Expert Software Migration Services | bluesBrackets
Data Center Migration & IT Migration Services
Expert Software Prototyping Services | Mobile, Embedded & Fullstack Prototyping
Mobile App Development Languages & Services
Expert IoT & Embedded Software Development | bluesBrackets
Quality Assurance Testing Services | bluesBrackets
End-to-End IT System Testing & Integration Services
Polish Software House: Agile Delivery & UI/UX
Medical Device Software Development Services
Healthcare IT Outsourcing & AI Software for Medical Innovators
Machine Learning for Predictive Analytics
Machine Learning Supply Chain Solutions
IT Nearshoring & Software Development Poland
Fixed Price vs. Time & Materials
Legacy Application Modernization Services
Legacy IT Systems Modernization & Custom Software Development
CTO as a Service - Future-Ready Software House: CTO, DevOps & UX/UI
Application Scaling for Startups | Scalable Solutions
Embedded Software Engineering Services | bluesBrackets
ReactJS Web Development Company
Build Scalable Desktop & Embedded Apps – bluesBrackets
Node.js, React & Next.js Development Poland – bluesBrackets
Flutter App Development Services | bluesBrackets
Poland’s Leading Java Software House | Hire Expert Java Developers
Machine Learning Consulting & Software Development Company Poland | UI/UX, Fullstack, Mobile, Embedded
Custom Software Development Services — bluesBrackets
Embedded & IoT Software Services | bluesBrackets
Software Development Companies | Custom Solutions
Expert Hardware Development Services | bluesBrackets
Custom AI Chatbot Solutions & Services
iOS PWA Development Services | Cross-Platform Mobile Apps
Expert iOS App Development Company in Poland
Expert Embedded Android & Bluetooth App Development
Software Engineering Outsourcing Poland
Specialized Software Engineering Services | bluesBrackets
Custom Web App Development Services | bluesBrackets
Progressive Web App Development Company | bluesBrackets Poland
Web Apps vs Desktop Apps: Expert Software
Web App vs Mobile App Development | Fullstack & UX/UI
Agile Software Development Company Poland
Software Development Outsourcing Company in Poland
Polish Software Development Outsourcing Company
Trusted Offshore Software Development Company in Poland
Industrial IoT Software Development Company
Polish Software House | Custom IoT & Embedded Solutions
IoT Software for Retail, Wearables, Property | bluesBrackets
Software Product Development Services | bluesBrackets
IoT Product Development Company | Embedded & Fullstack Software House
Enterprise Mobile App Development Company | bluesBrackets
IoT MQTT Dashboard & Custom Embedded Solutions
Bespoke MVP & Custom Software Development Company
Bespoke Software Development Company
Node.js Development Company | Trusted Node.js Services
Embedded Systems & Bare Metal Programming Experts | bluesBrackets
Custom Web App & AI Development Services
Custom CMS Solutions & Software Development
Custom Software Development Services in Poland
White Label Mobile & Embedded App Experts
Bespoke Software Solutions for Startups & Enterprises
Cloud Adoption & Digital Transformation Services
Cloud Application Development Services | Polish Cloud Development
Cloud Migration Consulting Services Company | bluesBrackets
Hire a Dedicated Development Team in Poland
Dedicated Software Development Teams in Europe
Integration & System Testing Experts
Software Integration & ChatGPT Integration Services
System to System Integration Services
Embedded Software Development Outsourcing
Embedded Software Staff Augmentation