ServerBuilder::BuildAndStart never returns if port unavailable.

252 views
Skip to first unread message

kkm.po...@gmail.com

unread,
Mar 28, 2016, 5:34:49 PM3/28/16
to grpc.io
I have a start-up sequence I stole from an example, and it works just fine, as long as the port I am binding to is available.

  std::string server_address("0.0.0.0:80");
  grpc::ServerBuilder builder;
  builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
  builder.RegisterService(....);
  std::unique_ptr<grpc::Server> server(builder.BuildAndStart());


However, when the port is unavailable, the call to BuildAndStart seems to never return (well, for the values of "never" as large as 5 minutes in my tests).

Is there a way to have the call fail quickly on binding failure? Is there a retry policy or something else that controls this behavior?

There are 2 messages logged:

E0328 14:25:16.763000000  2240 tcp_server_windows.c:174] bind addr=[::]:80: An attempt was made to access a socket in a way forbidden by its access permissions.
E0328 14:25:16.763000000  2240 server_chttp2.c:115] No address added out of total 1 resolved

 -kkm

Yang Gao

unread,
Apr 5, 2016, 7:33:49 PM4/5/16
to grpc.io, kkm.po...@gmail.com
Are you using a recent version of the code? I tried locally and could not reproduce it. BuildAndStart should return immediately with nullptr.

Thanks.
Reply all
Reply to author
Forward
0 new messages