Hi @sharan,
Thanks for sharing the details. I am using the same Nodejs server & client. 
Let me try this client configuration. 
Are you creating a headless service and adding a DNS entry in kubedns?


Here is my server & client files:

// Server.ts
...imports
const gRPCPort = config.GRPC_SERVER_PORT;
const options: protoLoader.Options = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
arrays: true,
oneofs: true,
};
const PROTO_FILE = '../proto/xyz.service.proto';
const packageDef = protoLoader.loadSync(
path.resolve(__dirname, PROTO_FILE),
options,
);
const proto = loadPackageDefinition(packageDef) as unknown as ProtoGrpcType;
const server = new Server();
// XYZ Services
server.addService(proto.xyz.xyzService.service, {
GetABC: (req, res) => getABCHandler(req, res),
} as XyzServiceHandlers);
server.bindAsync(
`0.0.0.0:${gRPCPort}`,
ServerCredentials.createInsecure(),
(err, port) => {
if (err) {
throw err;
}
console.log(`gRPC server listening on ${port}`);
server.start();
},
);

// Client.ts
const gRPCPort = config.GRPC_SERVER_PORT;
export const client = new proto.xyz.xyzService(
`0.0.0.0:${gRPCPort}`,
credentials.createInsecure()
);

const deadline = new Date();
deadline.setSeconds(deadline.getSeconds() + 1);
client.waitForReady(deadline, (err) => {
if (err) {
console.error(err);
return;
}
onClientReady();
});

function onClientReady() {
console.log("? gRPC Client is ready");
}

On Monday, February 6, 2023 at 4:25:01 PM UTC+5:30 Sharan Karthikeyan wrote:

> Please share your client connection file and the gRPC server connection 
> file.
>
> On Monday, 6 February, 2023 at 4:13:44 pm UTC+5:30 Sharan Karthikeyan 
> wrote:
>
>> I will give a step-by-step approach to solving this problem.
>> 1. You have a gRPC server. Make sure it is running on the "0.0.0.0:PORT" 
>> socket. And, make a cluster IP service to this gRPC pod. Assume we named it 
>> "grpc_service".
>> [image: Screenshot 2023-02-06 at 4.06.22 PM.png]
>> 2. Assume you have Node JS (REST API - CLIENT) listening on the 
>> Kubernetes service of your gRPC. ``config.OG_GRPC_SERVER = 
>> "grpc_service:PORT"
>> [image: Screenshot 2023-02-06 at 4.08.12 PM.png]
>>
>> If you do this, you will not need the 
>> "<serviceName>.<namespace>.svc.cluster.local:80" connection URL. I can you 
>> are facing an issue with connection in client.
>> On Monday, 6 February, 2023 at 3:43:30 pm UTC+5:30 Keyur Patel wrote:
>>
>>> I am using this on the client side: 
>>> "<serviceName>.<namespace>.svc.cluster.local:80". 
>>>
>>> On Monday, February 6, 2023 at 3:41:28 PM UTC+5:30 Sharan Karthikeyan 
>>> wrote:
>>>
>>>> Make sure gRPC server running on 0.0.0.0:PORT, so you have to make the 
>>>> connection to that socket from your client side. If you are using 
>>>> localhost:PORT in client side, it is pointing to the current pod's (client 
>>>> side - local machine) socket, hence you need change 0.0.0.0:PORT in both 
>>>> gRPC side (server) as well as your client side (Node or Apache or Go or 
>>>> etc).
>>>>
>>>>
>>>> On Monday, 6 February, 2023 at 3:37:06 pm UTC+5:30 Sharan Karthikeyan 
>>>> wrote:
>>>>
>>>>> Can you please share your client listening port and IP address?
>>>>> If you are using 127.0.0.1 (localhost), then change it to 0.0.0.0:PORT
>>>>> On Monday, 6 February, 2023 at 3:09:43 pm UTC+5:30 keyu...@gmail.com 
>>>>> wrote:
>>>>>
>>>>>> Hi @sharan,
>>>>>> Can you share your yaml files example? I am facing the same issue.
>>>>>>
>>>>>> On Monday, January 30, 2023 at 10:07:40 PM UTC+5:30 Sharan 
>>>>>> Karthikeyan wrote:
>>>>>>
>>>>>>> Actually, I found the answer. I have used the localhost socket in 
>>>>>>> the gRPC server, I changed it 0.0.0.0:PORT, and then it worked.
>>>>>>> Thank you for the response.
>>>>>>>
>>>>>>> On Friday, 20 January, 2023 at 4:21:39 am UTC+5:30 
>>>>>>> rbel...@google.com wrote:
>>>>>>>
>>>>>>>> Can you please provide more context? Your headless service should 
>>>>>>>> create a DNS entry in kubedns as you've described and the kubernetes 
>>>>>>>> NodeJS 
>>>>>>>> client should be able to resolve that DNS entry. Exactly what is the 
>>>>>>>> issue 
>>>>>>>> you are experiencing? 
>>>>>>>>
>>>>>>>> On Sunday, January 15, 2023 at 9:21:44 PM UTC-8 Sharan Karthikeyan 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> I have created a headless service in kubernetes for gRPC server. 
>>>>>>>>> But, I'm not able to connect that server in NodeJS client the 
>>>>>>>>> connection 
>>>>>>>>> url like this "bbl-org-server.default.svc.cluster.local" -- 
>>>>>>>>> "<serviceName>.<namespace>.svc.cluster.local". Please help me.
>>>>>>>>>
>>>>>>>>> Regards,
>>>>>>>>> Sharan
>>>>>>>>>
>>>>>>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/770ca0c0-1d9f-4880-8d9b-8b0b6e060c35n%40googlegroups.com.

Reply via email to