I'm trying to capture WebSocket traffic from Unity (I'm using ClientWebSocket from System.Net.WebSockets) with Charles and I can't see anything. Despite the app successfully sending messages to the WebSocket server, it appears that the app is bypassing the Charles proxy.
Here's my code snippet:
var source = new CancellationTokenSource();
var token = source.Token;
var socket = new ClientWebSocket();
socket.Options.Proxy = new WebProxy("http://localhost:8888", false);
await socket.ConnectAsync("ws://localhost:13000", token);
var message = "Hello, World";
var encoded = Encoding.UTF8.GetBytes(message);
await socket.SendAsync(new ArraySegment<byte>(encoded, 0, encoded.Length), WebSocketMessageType.Text, true, token);
I'm using Unity version 2022.3.13f1 and Charles version 4.6.3. Additionally, I tried using http://localhost.charlesproxy.com:8888 as the proxy URL without success.
It's also worth noting that if I use HttpWebRequest to make HTTP request from Unity, the requests are visible in Charles.
Any insights or suggestions on resolving this issue would be greatly appreciated.