Debug Server-Sent Events from OpenAPI with Proxyman

Cover Image for Debug Server-Sent Events from OpenAPI with Proxyman

Here is what we achieve in this tutorial:

  • Download and Setup Proxyman macOS
  • Start iOS Chat GPT Sample app and try to make some Chat with GPT-4o
  • 1 click to set up iOS Simulator with Proxyman and ready to capture HTTPS
  • Capture & Debug the Server-Sent Events from OpenAPI with Proxyman

In the end of this tutorial, you will be able to see the Server-Sent Events from OpenAPI with Proxyman.

Capture Server-Sent Events from OpenAPI with Proxyman and prettify it
Capture Server-Sent Events from OpenAPI with Proxyman and prettify it

With SSE and OpenAI Custom Tab -> It's easy to debug Server-Sent Events from OpenAPI

Prettify Server-Sent Events from OpenAPI with Proxyman
Prettify Server-Sent Events from OpenAPI with Proxyman

1. Get Started with Proxyman

Before we start, let's make sure you have Proxyman installed on your Mac.

  1. Head over to the Proxyman website and download the macOS version.
  2. Run the installer to set up Proxyman on your Mac.
  3. Launch Proxyman, navigate to the Certificate menu, and select "Install Certificate for this Mac..."
  4. Complete the on-screen steps to finish the certificate installation.
  5. Make sure the Proxyman certificate displays a green checkmark to confirm successful installation.
Install Proxyman certificate
Install Proxyman certificate

By following the steps above:

  • Proxyman CA Certificate is installed on your Mac and ready to capture HTTPS traffic from iOS Simulator.

2. Setup iOS Simulator with Proxyman

In order to capture HTTPS traffic from iOS Simulator, we need to setup Proxyman with iOS Simulator.

  1. Open Xcode, download this Sample App: GPTClientApp-iOS and start it with iOS 18 Simulators.
  2. Open Proxyman, navigate to certificate Menu -> Install Certificate for iOS -> Simulator
  3. Click on "Prepare Simulators" button
  4. Click on "Reboot" button and re-start your iOS app from Xcode.
  5. Done! It's ready to capture HTTPS traffic with Proxyman
Setup iOS Simulator with Proxyman
Setup iOS Simulator with Proxyman

This is the most simple and recommended way to capture HTTPS traffic from iOS Simulator with Proxyman. No need to manually set up HTTP Proxy and Trust self-signed certificate like other web proxy tools, like Charles, Fiddler, etc.

3. Debug Server-Sent Events from OpenAPI with Proxyman

  1. In Xcode, start the iOS Chat GPT Sample app and try to Chat with GPT-4o. It's crucial because GPT Sample App will make a first request to OpenAI API, so Proxyman can capture it.
  2. Open Proxyman -> You can use Command + F to search for "api.openai.com" -> You will see the first request to OpenAI API.
Search for OpenAI API in Proxyman
Search for OpenAI API in Proxyman
  1. Look at the Response Panel -> Click on "Enable only this domain"
Enable only this domain in Proxyman
Enable only this domain in Proxyman

By doing it, it tells Proxyman to capture & decrypt HTTPS traffic from https://openai.com

  1. Now, restart your iOS app, and start asking questions to GPT.

  2. At this point, you can see the Server-Sent Events from OpenAPI with Proxyman in the Response Body

Capture Server-Sent Events from OpenAPI with Proxyman
Capture Server-Sent Events from OpenAPI with Proxyman

3.1 Use SSE and OpenAI custom tab for better debugging

If you can notice from the Response Body, Server-Sent Event sent a bunch of fragment data and it's hard to read

Server-Sent Events from OpenAPI with Proxyman
Server-Sent Events from OpenAPI with Proxyman

To make it easier to read, let's click on the "Prettify Body" on the top of the Response Body (If you can't find it, please click on the "+" button on the Response Toolbar -> Select "SSE" and "OpenAI" from Response Column)

Prettify Server-Sent Events from OpenAPI with Proxyman
Prettify Server-Sent Events from OpenAPI with Proxyman

Voila! Now you can see the Server-Sent Events from OpenAPI with Proxyman in a more readable format.

SSE Tab

  • ✅ Proxyman keeps the SSE data but try to prettify the JSON data.
SSE Tab in Proxyman
SSE Tab in Proxyman

OpenAI Tab

  • ✅ Proxyman tries to accumulate the OpenAI's content key and show the final result. It's Similar to what we see in the ChatGPT app.
OpenAI Tab in Proxyman
OpenAI Tab in Proxyman

3.2 What next?

  • Proxyman can capture HTTPS traffic from iOS device, iOS Simulator and Android devices.

Proxyman is a high-performance macOS/Windows/Linux app, which enables developers to capture HTTPs traffic on iOS device, iOS Simulator and Android devices.

Get it at https://proxyman.com

Noah Tran
Noah Tran