-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unix domain socket #756
Comments
Unfortunately, the Node.js In general, we aim to not replicate every gRPC feature, and rely on the standard library of the underlying platform. If Node.js were to support UDS in If someone comes up with a reliable alternative to |
I may be missing something, but I believe import * as http2 from 'node:http2'
const server = http2.createServer()
server.on('stream', (stream, headers) => {
stream.respond({
'content-type': 'text/html charset=utf-8',
':status': 200,
})
stream.end('<h1>Hello World</h1>')
})
// server.listen(8000)
server.listen('./example.sock')
|
I'm glad you brought up the example, Jacob - I should have been more precise. Yes, you can listen to an UDS with an |
Ah, fun. So it looks like http2.connect('http://example', {
createConnection: (authority, option) => {
return net.connect('./example.sock');
},
}) It looks like it's also possible to pass that as an option to |
Yup, I can confirm that this works on Linux. Using import { createGrpcTransport } from "@connectrpc/connect-node";
import { connect as nodeConnect } from "node:net";
const socket = "/path/to/socket"
const transport = createGrpcTransport({
httpVersion: "2",
baseUrl: "http://socket.localhost", // not a real URL, socket is in nodeOptions.createConnection
nodeOptions: {
createConnection: () => {
return nodeConnect(socket)
},
},
}) |
This is a good plan, however Deno complains about leaking resources |
I believe you should be able to simplify and use https://nodejs.org/api/http2.html#http2connectauthority-options-listener const client: ClientHttp2Session = connect('http://localhost:0', { path: '/path/to/uds' }); |
Is your feature request related to a problem? Please describe.
With other gRPC libraries, I'm able to connect to a gRPC server listening on a unix domain socket (e.g.
unix:///path/to/server.sock
).Describe the solution you'd like
I don't think this is possible with
createGrpcTransport()
at the moment, but it would be awesome if it was.Describe alternatives you've considered
At the moment, I have to use another gRPC client library - I'd prefer to use
@bufbuild/connect
instead.The text was updated successfully, but these errors were encountered: