grpc: Python client cannot communicate with C# server using unix socket
What version of gRPC and what language are you using?
Python gRPC 1.57.0 (1.58.0 is also affected, 1.56.0 is NOT affected)
What operating system (Linux, Windows,…) and version?
Linux (Ubuntu 22.04)
What runtime / compiler are you using (e.g. python version or version of gcc)
Python 3.10.12 (but same issue with Python 3.7-slim docker)
What did you do?
- Launch a C# Kestrel server running a gRPC service and listening on a unix socket
- Launch a Python client to send a request to said service
What did you expect to see?
Request succeeding
What did you see instead?
With Python gRPC 1.57.0
File "/home/dbrasseur/repro/main.py", line 18, in <module>
main('test')
File "/home/dbrasseur/repro/main.py", line 13, in main
response: TestResponse = stub.Test(TestRequest(test_string=name))
File "/home/dbrasseur/repro/env/lib/python3.10/site-packages/grpc/_channel.py", line 1161, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/home/dbrasseur/repro/env/lib/python3.10/site-packages/grpc/_channel.py", line 1004, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INTERNAL
details = "Received RST_STREAM with error code 1"
debug_error_string = "UNKNOWN:Error received from peer {grpc_message:"Received RST_STREAM with error code 1", grpc_status:13, created_time:"2023-09-11T16:41:48.035594769+02:00"}"
Kestrel rejects the connection with the following error :
dbug: Microsoft.AspNetCore.Server.Kestrel.Http2[35]
Trace id "0HMTIQSGVMTK9:00000001": HTTP/2 stream error "PROTOCOL_ERROR". A Reset is being sent to the stream.
Microsoft.AspNetCore.Connections.ConnectionAbortedException: Invalid Host header: 'tmp%2Fsrv.sock'
Note that unix sockets work between Python clients and Python servers This bug is present in the 1.57.0, and 1.58.0 releases This bug is NOT present in 1.56.0
Anything else we should know about your project / environment?
You can find a “simple” reproduction example here : https://github.com/dbrasseur-aneo/grpc1.57bug To use this reproduction example you need :
- bash
- python 3.7+
- dotnet 6.0+
Follow the reproduction steps:
- Run ./build.sh to create the virtualenv, to generate the proto files and to build the dotnet server
- Run ./run-working.sh to see that the unix socket works between python client and server
- Run ./run.sh to see that it doesn't work between a python client and a C# server
About this issue
- Original URL
- State: open
- Created 10 months ago
- Comments: 18 (12 by maintainers)
I wouldn’t say this is “expected”, really. What’s suggested is more of a workaround, since we believe the headers being sent by default are valid, but are being rejected by the server as invalid.
Looks like this is expected, can you try override the authority by setting the GRPC_ARG_DEFAULT_AUTHORITY channel arg?