From a3acb470ef9192c4dbbe2c2a84385e49080fcf7f Mon Sep 17 00:00:00 2001 From: Peter Kanev Date: Mon, 18 Dec 2017 11:31:20 +0200 Subject: [PATCH 1/2] fix generating port for debug socket when debugging ios with chrome devtools When generating a port to start a websocket on, use the same logic as is present in the android debug service - get the first available available port in a range, and reuse it for the next debug session of the same application if it is still available --- lib/device-sockets/ios/socket-proxy-factory.ts | 2 +- test/services/ios-debug-service.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/device-sockets/ios/socket-proxy-factory.ts b/lib/device-sockets/ios/socket-proxy-factory.ts index 33a75b7b03..255201a984 100644 --- a/lib/device-sockets/ios/socket-proxy-factory.ts +++ b/lib/device-sockets/ios/socket-proxy-factory.ts @@ -74,7 +74,7 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact public async createWebSocketProxy(factory: () => Promise): Promise { // NOTE: We will try to provide command line options to select ports, at least on the localhost. - const localPort = await this.$net.getFreePort(); + const localPort = await this.$net.getAvailablePortInRange(41000); this.$logger.info("\nSetting up debugger proxy...\nPress Ctrl + C to terminate, or disconnect.\n"); diff --git a/test/services/ios-debug-service.ts b/test/services/ios-debug-service.ts index 23af05478b..d994ea9cbd 100644 --- a/test/services/ios-debug-service.ts +++ b/test/services/ios-debug-service.ts @@ -48,6 +48,10 @@ const createTestInjector = (): IInjector => { on: (event: string | symbol, listener: Function): any => undefined }); + testInjector.register("net", { + getAvailablePortInRange: async (startPort: number, endPort?: number): Promise => 41000 + }); + return testInjector; }; From a82b4f1da6400a38ed789bfc45679fe5f4a25931 Mon Sep 17 00:00:00 2001 From: Martin Bektchiev Date: Thu, 4 Jan 2018 14:04:46 +0200 Subject: [PATCH 2/2] fix(device-socket): iOS Socket proxy should listen on IPv4 localhost addapter Check for available port is done on this adapter and by default server is launched on "::" which is IPv6's any adapter --- lib/device-sockets/ios/socket-proxy-factory.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/device-sockets/ios/socket-proxy-factory.ts b/lib/device-sockets/ios/socket-proxy-factory.ts index 255201a984..3e8de7cf62 100644 --- a/lib/device-sockets/ios/socket-proxy-factory.ts +++ b/lib/device-sockets/ios/socket-proxy-factory.ts @@ -85,6 +85,7 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact const server = new ws.Server({ port: localPort, + host: "localhost", verifyClient: async (info: any, callback: Function) => { this.$logger.info("Frontend client connected."); let _socket;