# \[Feature Requst\] add GRPC support to pritunl-zero

**URL:** <https://forum.pritunl.com/t/feature-requst-add-grpc-support-to-pritunl-zero/2619>\
**Category:** Pritunl Zero\
**Tags:** pritunl-zero\
**Created:** [November 21, 2024, 1:27pm UTC](https://forum.pritunl.com/t/feature-requst-add-grpc-support-to-pritunl-zero/2619 "2024-11-21T13:27:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wenpin.cui](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/w/a9adbd/32.png) [@wenpin.cui](https://forum.pritunl.com/u/wenpin.cui)\
**Post date:** [November 21, 2024, 1:27pm UTC](https://forum.pritunl.com/t/feature-requst-add-grpc-support-to-pritunl-zero/2619/1 "2024-11-21T13:27:50Z")

</div>

Hi, @zach

We want to put a grpc server behind pritunl-zero, during testing we found the request can pass pritunl-zero, but failed with bellow error:

`rpc error: code = Internal desc = server closed the stream without sending trailers`

According to the source code looks pritunl-zero is using http transport not http2 - [pritunl-zero/proxy/web.go at master · pritunl/pritunl-zero · GitHub](https://github.com/pritunl/pritunl-zero/blob/master/proxy/web.go#L164-L180)

This might be the root cause of the failure.

This is an example of revsere proxying grpc, seems we need to use http2 transport - [net/http/httputil: Grpc over Go Proxy brings always connection error (help wanted) · Issue #29928 · golang/go · GitHub](https://github.com/golang/go/issues/29928#issuecomment-458743053)

Is it possible to implement grpc support? Thanks.

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [November 21, 2024, 9:20pm UTC](https://forum.pritunl.com/t/feature-requst-add-grpc-support-to-pritunl-zero/2619/2 "2024-11-21T21:20:41Z")

</div>

Support for HTTP/2 which includes gRPC has been added to the repository [**pritunl/pritunl-zero:e176707**](https://github.com/pritunl/pritunl-zero/commit/e1767073010e92e8b3778a1bb27cadbd4c683380). It was tested with gRPC with and without TLS. There is still some uncommited code for the service option to enable/disable HTTP/2 support. This will be included in the next release.

---

<div class="post-metadata">

**Author:** ![wenpin.cui](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/w/a9adbd/32.png) [@wenpin.cui](https://forum.pritunl.com/u/wenpin.cui)\
**Post date:** [November 22, 2024, 1:19am UTC](https://forum.pritunl.com/t/feature-requst-add-grpc-support-to-pritunl-zero/2619/3 "2024-11-22T01:19:14Z")

</div>

Thanks, @zach for the quick response and kind support.

Do we have an ETA of next release?

---

<div class="post-metadata">

**Author:** ![wenpin.cui](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/w/a9adbd/32.png) [@wenpin.cui](https://forum.pritunl.com/u/wenpin.cui)\
**Post date:** [December 3, 2024, 6:12am UTC](https://forum.pritunl.com/t/feature-requst-add-grpc-support-to-pritunl-zero/2619/4 "2024-12-03T06:12:16Z")

</div>

Hi, @zach . We still had issue with lastet pritunl-zero.

I’ve verified that we need to include this change to make grpc work end to end.

btw in our setup, the pritunl-zero node is configured with HTTP protocol. I think that’s why we must have `h2c.NewHandler`.

```auto
diff --git a/router/router.go b/router/router.go
index 117cac58..db2a09ed 100644
--- a/router/router.go
+++ b/router/router.go
@@ -6,6 +6,8 @@ import (
 	"crypto/md5"
 	"crypto/tls"
 	"fmt"
+	"golang.org/x/net/http2"
+	"golang.org/x/net/http2/h2c"
 	"io"
 	"math/rand"
 	"net/http"
@@ -248,9 +250,10 @@ func (r *Router) initWeb() (err error) {
 	writeTimeout := time.Duration(settings.Router.WriteTimeout) * time.Second
 	idleTimeout := time.Duration(settings.Router.IdleTimeout) * time.Second

+	h2s := &http2.Server{}
 	r.webServer = &http.Server{
 		Addr: fmt.Sprintf(":%d", r.port),
- Handler: r,
+ Handler: h2c.NewHandler(r, h2s),
 		ReadTimeout: readTimeout,
 		ReadHeaderTimeout: headerTimeout,
 		WriteTimeout: writeTimeout,

```

Can you review it?

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [December 8, 2024, 7:55am UTC](https://forum.pritunl.com/t/feature-requst-add-grpc-support-to-pritunl-zero/2619/5 "2024-12-08T07:55:19Z")

</div>

This change has been added to the repository and will be included in the next release.

It will only be enabled if the node protocol is set to HTTP.
