We are currently experimenting with grpc and json transcoding to enable a delphi client to make server calls. In our stack we have python 3.10 and .net services.
The json transcoding is done using .net 7 with the https://www.nuget.org/packages/Microsoft.AspNetCore.Grpc.JsonTranscoding package. For testing purposes I defined three ports where each accepts different http protocol versions.
webBuilder.UseKestrel(kestrelOptions =>
{
kestrelOptions.ListenAnyIP(5000, listenOptions =>
{
listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1;
});
kestrelOptions.ListenAnyIP(5001, listenOptions =>
{
listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2;
});
kestrelOptions.ListenAnyIP(5002, listenOptions =>
{
listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1AndHttp2;
});
});
- On port 5000 grpc does not work but the service can be called with json transcoding.
- On port 5001 grpc does work with a python client and a .net7 client. Json transcoding does not work.
- On port 5002 grpc works only with the .net7 client json transcoding works. The python client produces following error:
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses; last error: UNAVAILABLE: ipv4:127.0.0.1:5000: Failed parsing HTTP/2"
debug_error_string = "UNKNOWN:failed to connect to all addresses; last error: UNAVAILABLE: ipv4:127.0.0.1:5000: Failed parsing HTTP/2 {created_time:"2022-11-08T07:07:49.2047503+00:00", grpc_status:14}"
>
It seems the python client does not support protocol negotiation. Is there some way to use the json transcoding and only use a single port with both protocols enabled?
Versions used:
- .net 7.0.100-rc.2.22477.23
- Microsoft.AspNetCore.Grpc.JsonTranscoding 7.0.0-rc.2.22476.2
- python 3.10.1
- grpcio 1.50.0