fix(mobile): bypass injected URLProtocol classes on iOS websockets
Verified on the simulator: the socket completed its 101 (with permessage-deflate negotiated) and then died instantly with NSURLErrorDomain -1005, so JS never saw an open event and the supervisor reconnected every 15s. The dev client registers custom URLProtocol classes for its network inspector; they intercept URLSession traffic and do not understand the WebSocket upgrade. Clearing protocolClasses on the session config fixes it: one stable socket, no reconnects over 60s. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
843adadac2
commit
926ff9baaa
1 file changed
+9
-5
@@ -58,11 +58,15 @@ private final class T3WebSocketConnections: NSObject, URLSessionWebSocketDelegat
|
||||
private var idsByTaskIdentifier: [Int: Int] = [:]
|
||||
private var emittersById: [Int: T3WebSocketEmitter] = [:]
|
||||
|
||||
private lazy var session = URLSession(
|
||||
configuration: .default,
|
||||
delegate: self,
|
||||
delegateQueue: nil
|
||||
)
|
||||
private lazy var session: URLSession = {
|
||||
let configuration = URLSessionConfiguration.default
|
||||
// Dev clients (and network debuggers) register custom URLProtocol classes
|
||||
// that intercept URLSession traffic. They do not understand the WebSocket
|
||||
// upgrade and drop the connection right after the 101 (NSURLErrorDomain
|
||||
// -1005). WebSocket traffic has no reason to go through them.
|
||||
configuration.protocolClasses = []
|
||||
return URLSession(configuration: configuration, delegate: self, delegateQueue: nil)
|
||||
}()
|
||||
|
||||
func open(id: Int, url: URL, protocols: [String], emitter: @escaping T3WebSocketEmitter) {
|
||||
queue.async {
|
||||
|
||||
Reference in new issue
Block a user