99designs / 99designs/gqlgen

Subscription error: Error: Socket closed with event 1002 RSV1 set, bad opcode 7, bad MASK at Object.error

Đang mở
#3,007 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
10.8k
Fork
1.3k
Merge trung bình
2 ngày 36 phút
Pull request đã merge (30 ngày)
26

Mô tả

I followed the gqlgen guide on setting up graphql in a Gin project and then tried to also add support for subscriptions.
Everything works flawlessly except for subscriptions.
When testing it out in the playground, I get the following error:

`Error: Socket closed with event 1002 RSV1 set, bad opcode 7, bad MASK at Object.error`

Screenshot 2024-04-15 at 06 44 29

I am sure I am just missing something or made a mistake in my configuration, but for the life of me, cannot see where.

I created the following graphql handler which includes the AddTransport method for subscriptions:

```go
// graphql.go

func GraphqlHandler() gin.HandlerFunc {
// NewExecutableSchema and Config are in the generated.go file
// Resolver is in the resolver.go file
h := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}))

h.AddTransport(&transport.Websocket{}) // <== Added Subscription support

return func(c *gin.Context) {
h.ServeHTTP(c.Writer, c.Request)
}
}

// Defining the Playground handler
func PlaygroundHandler() gin.HandlerFunc {
h := playground.Handler("GraphQL", "/query")

return func(c *gin.Context) {
h.ServeHTTP(c.Writer, c.Request)
}
}
```

My routes file:
```go
// routes.go
func SetupRouter() *gin.Engine {
r := gin.Default()

// ... removed for brevity

r.Any("/query", graphql.GraphqlHandler())
r.GET("/", graphql.PlaygroundHandler())

// ... removed for brevity

return r
}
```

I would appreciate any assistance.
Many thanks!

### versions
- gqlgen version: `v0.17.45`
- go version: `go1.21.5 darwin/arm64`

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.