atlantis
atlantis copied to clipboard
Support WebSocket
Description
We can do "Method Swizzling" for send(_:completionHandler:)
and receive(completionHandler:)
from URLSessionWebSocketTask
to capture the WS/WSS messages.
We should support this feature 👍
Acceptance Criteria
- Do "Method Swizzling" to URLSessionWebSocketTask
- Able to send the message to Proxyman for the inspector
If you have the same feature request, please add 👍 on this ticket.
this would be really helpful .. is there a easy way to add sending the data manually over the library ?
@bastianh It's possible to manually send the request/response to Proxyman by Atlantis. Please check out https://github.com/ProxymanApp/atlantis#advanced-usage
It's useful for apps that are using GRPC, C++ libraries, or other formats that haven't supported yet 👍
Yes.. I saw that .. but I have no idea how to do that for a websocket connection..
I'm starting it with this snippet:
let webSocketTask = URLSession.shared.webSocketTask(with: url)
and then get only callbacks for message that I receive.
Sorry for this. The code I show you only work with HTTP/HTTPS request/response, not WS/WSS for now :/
I will add this feature to the next release 👍
great... thank you
The good news here 🎉
I'm working on this ticket, so we can capture the WS/WSS from your iOS with ease.
This feature might be a reasonable solution to fix the bug that Proxyman app couldn't capture WS/WSS from URLSessionWebsocketTask (https://github.com/ProxymanApp/Proxyman/issues/586#issuecomment-720197948)
I've just tried this new update, and it's working with WSS from URLSessionWebsocketTask 😀! Thanks for the update!
However I also tried it on Starscream and it didn't work 😕. I've read their source code and it seems like they're not using __NSURLSessionWebSocketTask
but instead some low level CoreFoundation API CFStreamCreatePairWithSocketToHost
?
Do you have any idea how to approach that? It doesn't seem like a method that can be swizzled? Seems to me like a function.. (I'm not super fluent with Objective-C)
@youjinp let set useCustomEngine: false
, so Starscream can use Native Engine (URLSessionWebsocket).
let socket = WebSocket(request: URLRequest(url: URL(string: "wss://echo.websocket.org")!), useCustomEngine: false)
For low-level CoreFoundation API CFStreamCreatePairWithSocketToHost, I suppose that it's impossible to do Method Swizzling because it's a C func, not Objective-C
Yep. Thought so 👍
@youjinp Just a friendly reminder that Atlantis has supported WS/WSS from URLSessionWebSocketTask 👍
Release: https://github.com/ProxymanApp/atlantis/releases/tag/1.9.0