Skip to content

Generate debug port in range for Chrome DevTools websocket - iOS #3275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/device-sockets/ios/socket-proxy-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact

public async createWebSocketProxy(factory: () => Promise<net.Socket>): Promise<ws.Server> {
// 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");

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

const server = new ws.Server(<any>{
port: localPort,
host: "localhost",
verifyClient: async (info: any, callback: Function) => {
this.$logger.info("Frontend client connected.");
let _socket;
Expand Down
4 changes: 4 additions & 0 deletions test/services/ios-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number> => 41000
});

return testInjector;
};

Expand Down