Skip to content
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

panic: repeated read on failed websocket connection #144

Open
2 tasks done
JohnKinyanjui opened this issue Aug 13, 2024 · 1 comment
Open
2 tasks done

panic: repeated read on failed websocket connection #144

JohnKinyanjui opened this issue Aug 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@JohnKinyanjui
Copy link

JohnKinyanjui commented Aug 13, 2024

Describe the bug

Am not sure but i think this error might by gorilla websocket please consider to switch to a better library, it unable to handle websocket correctly but if its from my end let me know

Steps to reproduce

this is my simple middleware in golang for echo, i use it to authorize tokens on the rest api

func AuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc {

	return func(c echo.Context) error {
		token := c.Request().Header.Get("Authorization")
		tokenString := strings.Split(token, " ")
		if len(tokenString) != 2 {
			return c.JSON(http.StatusUnauthorized, map[string]string{"message": "missing or invalid token"})
		}

		db, err := database.Connection(tokenString[1])
		if err != nil {
			return c.JSON(http.StatusUnauthorized, map[string]string{"message": "invalid token"})
		}
		defer db.Close()

		c.Set("db", db)

		return next(c)
	}
}

Expected behaviour

panic: repeated read on failed websocket connection

goroutine 315 [running]:
github.com/gorilla/websocket.(*Conn).NextReader(0xc000557b80)
        C:/Users/hp/go/pkg/mod/github.com/gorilla/[email protected]/conn.go:1055 +0x28d
github.com/gorilla/websocket.(*Conn).ReadMessage(0xc00025ff70?)
        C:/Users/hp/go/pkg/mod/github.com/gorilla/[email protected]/conn.go:1120 +0x13
github.com/surrealdb/surrealdb.go/internal/websocket.(*WebSocket).read(0xc0005b04e0?, {0x12f51e0, 0xc0003359e0})
        C:/Users/hp/go/pkg/mod/github.com/surrealdb/[email protected]/internal/websocket/ws.go:140 +0x25
github.com/surrealdb/surrealdb.go/internal/websocket.(*WebSocket).initialize.func1()
        C:/Users/hp/go/pkg/mod/github.com/surrealdb/[email protected]/internal/websocket/ws.go:167 +0x5e
created by github.com/surrealdb/surrealdb.go/internal/websocket.(*WebSocket).initialize in goroutine 351
        C:/Users/hp/go/pkg/mod/github.com/surrealdb/[email protected]/internal/websocket/ws.go:160 +0x4f

SurrealDB version

1.5.4 for windows on x86_64

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@JohnKinyanjui JohnKinyanjui added the bug Something isn't working label Aug 13, 2024
@ElecTwix
Copy link
Contributor

ElecTwix commented Aug 13, 2024

Am not sure but i think this error might by gorilla websocket please consider to switch to a better library, it unable to handle websocket correctly but if its from my end let me know

Hi @JohnKinyanjui thanks for your issue, I did propose to switch long before. it wasn't accepted #127. Then, PR was created to replace WS, which has still not been reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants