server builder not starting

129 views
Skip to first unread message

Poojitha A

unread,
Dec 7, 2015, 2:26:51 AM12/7/15
to grpc.io
Hi ,

This is the part of my code that checks for tls and creates the creds accordingly. 


        std::string server_add(server_address.str());
        ServerBuilder builder;
        std::shared_ptr<ServerCredentials> creds;
        if(tls)
        {
               
                std::ifstream readkeyfile(keyfilename);
                std::stringstream buffer;
                buffer << readkeyfile.rdbuf();
                std::string key=buffer.str();
                std::ifstream readcertfile(cafilename);
                buffer << readcertfile.rdbuf();
                std::string cert=buffer.str();
                SslServerCredentialsOptions::PemKeyCertPair pkcp ={key,cert};
                SslServerCredentialsOptions ssl_opts;
                ssl_opts.pem_root_certs="";
                ssl_opts.pem_key_cert_pairs.push_back(pkcp);
                creds = SslServerCredentials(ssl_opts);
        }
        else
        {
                creds=grpc::InsecureServerCredentials();
        }
    builder.AddListeningPort(server_add,creds);
    builder.RegisterService(this);
    server=builder.BuildAndStart();
    server->Wait();
    return 1;

When I run the server its is failing at the build and start. When tls is enabled the code is exiting while for unsecure credentials its getting hung. 
can someone help resolve this. 

Poojitha A

unread,
Dec 8, 2015, 7:19:31 PM12/8/15
to grpc.io
Any inputs on why the server is hanging on BuildAndStart? I tried running gdb but it seems to be not showing any useful info. 

Jorge Canizales

unread,
Dec 8, 2015, 7:58:50 PM12/8/15
to grpc.io, Yang Gao
+Yang

Yang Gao

unread,
Dec 8, 2015, 8:01:49 PM12/8/15
to Jorge Canizales, grpc.io
Your code looks fine. Without further information, I cannot tell why it did not work.

Poojitha A

unread,
Dec 13, 2015, 8:37:48 AM12/13/15
to Yang Gao, Jorge Canizales, grpc.io
I guess its failing at buildandstart. I see there is a for loop that is looking for some port begin and end. I suspect its there.  

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAB1HKY5iXO5cssQFQBQoWCbtfBPGHHvaoOXP221-r%2B3kBn%3Di5Q%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages