diff --git a/app/composables/grpcws/bridge/index.ts b/app/composables/grpcws/bridge/index.ts index a9e186092..eda845fe7 100644 --- a/app/composables/grpcws/bridge/index.ts +++ b/app/composables/grpcws/bridge/index.ts @@ -43,6 +43,7 @@ export class GrpcWSTransport implements RpcTransport { delay: 1150, }, protocols: ['grpc-websocket-channel'], + onConnected(ws) { ws.binaryType = 'arraybuffer'; wsInitiated.value = true; diff --git a/pkg/server/http.go b/pkg/server/http.go index ee15cc3b2..5f1ae2547 100644 --- a/pkg/server/http.go +++ b/pkg/server/http.go @@ -198,7 +198,14 @@ func NewEngine(p EngineParams) (*gin.Engine, error) { grpcws.WithWebsocketPingInterval(40*time.Second), ) ginWrappedGrpc := func(c *gin.Context) { - c.Request.RemoteAddr = c.ClientIP() + if cip := c.ClientIP(); cip != "" { + if strings.Count(cip, ":") > 1 { + c.Request.RemoteAddr = "[" + cip + "]:80" + } else { + c.Request.RemoteAddr = cip + ":80" + } + } + wrapperGrpc.ServeHTTP(c.Writer, c.Request) } e.Any("/api/grpc", ginWrappedGrpc)