-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Feature Request: expose handleRawConn or add ServeConn #7315
Comments
@CoiaPrant233 I will take a look and get back to you |
@CoiaPrant233 could you describe your use case for this request? |
gRPC in websocket.Conn |
Could you please be more specific. |
I wrapped a websocket implement net.Conn, but its required block I/O. If http handler function was returned. websocket will be closed automatically. |
Could you explain what is your usecase that needs websocket connection? Is it for a web application? In case you haven't yet, take a look at grpc Bidirectional Streaming and see if that can help with your usecase |
Some middleware without http/2 or grpc support. |
So must add a websocket wrapping let connection passthrough middleware. |
Have you tried exploring grpc-web? This allows grpc to work over HTTP/1.1 which is supported by cloudfare. |
Yes, but I need Bi-directional stream. |
@CoiaPrant233 you can try using an HTTP tunnel (also called HTTP Connect Proxy). This should allow you to bypass the middleware if the HTTP 1.1 proxy server is placed behind the middleware. |
I want to passthrough CDN to protect origin server. |
Providing a custom way to handle the incoming connection is not something we are very keen on doing. Would one of the following options work for you?
|
I tried them. But it has some bugs. |
Could you provide details on what you tried and what bugs you found? Thanks. |
WebSocket library not has wait close function, I tried wrapped to net.Listener, but I can't immediately determine if the connection is closed. It looks like terrible. In a high concurrency environment, a websocket object will be held for a long time and will not be released even if it is closed. |
From your wrapped
I don't know much about websocket, but gRPC does provide a way to close connections that have been open for more than a configurable time. See here: https://pkg.go.dev/google.golang.org/grpc/keepalive#ServerParameters What issues did you run into when running your own proxy to terminate the websocket connection? |
I think blocking IO is better. Just add a new function. or u can removed async call in handleRawConn At server.go#L926 already call async function I think its useless to call twice async. u can modify it like ServeHTTP from
to
then I can use unsafe to force expose it |
I think add new function We need blocking I/O for serve single connection. |
This issue is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
anyone here? |
This issue is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
anyone here? |
@CoiaPrant233 could you provide more details on how you are implementing |
Here is a example |
@CoiaPrant233 you need to first implement a custom
This way, as suggested above, your wrapped With a listener we just call |
Use case(s) - what problem will this feature solve?
gRPC in custom implemented net.Conn
Proposed Solution
expose
handleRawConn
Alternatives Considered
add
ServeConn
interfaceAdditional Context
ServeConn should block
to
The text was updated successfully, but these errors were encountered: