Skip to content
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

Support OS allocated random TCP port #20

Closed
nicolaslt opened this issue Jan 10, 2018 · 1 comment
Closed

Support OS allocated random TCP port #20

nicolaslt opened this issue Jan 10, 2018 · 1 comment

Comments

@nicolaslt
Copy link

Hi,

We would like to let the OS decide on which port our gRPC service listens on. This is achieved by passing port 0 all the way down.

Requesting for a random port already works, but we have no way of knowing which port is allocated because rxjs-grpc doesn't expose the return value of this line.

Any chance you could expose it?
Thank you

@kondi kondi closed this as completed in 2c1841a Mar 13, 2019
@kondi
Copy link
Owner

kondi commented Mar 13, 2019

You can achieve it now by passing the grpc.Server instance to the serverBuilder.

const grpcServer = new grpc.Server();
const server = serverBuilder<helloworld.ServerBuilder>('helloworld.proto', 'helloworld', grpcServer);

// server.addGreeter({ ... });

const port = grpcServer.bind('0.0.0.0:0', grpc.ServerCredentials.createInsecure());
grpcServer.start();
console.log(`Listening on port ${port}`);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants