Skip to content

Commit 96f476c

Browse files
petekanevMartin Bektchiev
authored and
Martin Bektchiev
committed
Generate debug port in range for Chrome DevTools websocket - iOS (#3275)
* 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 * fix(device-socket): iOS Socket proxy should listen on IPv4 localhost adapter Check for available port is done on this adapter and by default server is launched on "::" which is IPv6's any adapter
1 parent 84a2bd3 commit 96f476c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/device-sockets/ios/socket-proxy-factory.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact
7474

7575
public async createWebSocketProxy(factory: () => Promise<net.Socket>): Promise<ws.Server> {
7676
// NOTE: We will try to provide command line options to select ports, at least on the localhost.
77-
const localPort = await this.$net.getFreePort();
77+
const localPort = await this.$net.getAvailablePortInRange(41000);
7878

7979
this.$logger.info("\nSetting up debugger proxy...\nPress Ctrl + C to terminate, or disconnect.\n");
8080

@@ -85,6 +85,7 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact
8585

8686
const server = new ws.Server(<any>{
8787
port: localPort,
88+
host: "localhost",
8889
verifyClient: async (info: any, callback: Function) => {
8990
this.$logger.info("Frontend client connected.");
9091
let _socket;

test/services/ios-debug-service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ const createTestInjector = (): IInjector => {
4848
on: (event: string | symbol, listener: Function): any => undefined
4949
});
5050

51+
testInjector.register("net", {
52+
getAvailablePortInRange: async (startPort: number, endPort?: number): Promise<number> => 41000
53+
});
54+
5155
return testInjector;
5256
};
5357

0 commit comments

Comments
 (0)