Extend gRPC to use a custom connection that was created by a UDP punched hole

130 views Asked by At

Since there seems to be no simple way to create a gRPC channel between two nodes sitting behind NAT devices, I need to figure out how to use the connection created by a UDP punched hole.

I have successfully written code that will do the normal P2P operations to have clients register their external address/port with a rendezvous server. I can get connected through this relay and then by quickly sending a couple of ping messages, the "holes" can be punched through the NAT device. This is a standard P2P design pattern. Once I have the hole punched, I need to create a gRPC channel between these two clients using the UDP sockets created by the above operations.

When I try to do the GrpcChannel.ForAddress and use this channel to create a gRPC client, I get the dreaded "connection rejected by server" error. When I ask ChatGPT or BingAI, it tells me I need to create a custom gRPC socket handler, but I cannot find any documentation on how to do this. One AI-generated answer indicated there is a way to configure the .net UdpClient to allow multiple connections on a single port... I am haven't tried that yet, but will do so now... I am using C# and .NET 7. If anyone knows what documents or code library which does such a thing, I'd be eternally grateful for you sharing this vital bit of information!!!

Thanks, Steve

0

There are 0 answers