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

How to use custom websockets[BUG] #2412

Open
juxiaoming opened this issue Apr 7, 2024 · 0 comments
Open

How to use custom websockets[BUG] #2412

juxiaoming opened this issue Apr 7, 2024 · 0 comments
Assignees

Comments

@juxiaoming
Copy link

juxiaoming commented Apr 7, 2024

app := iris.New()
appRouter := app.Party("/api")
appRouter.PartyFunc("/record", func(request router.Party) {
        request.Any("/ws", hero.Handler(newRecordHandler.Ws))
})
var upgrader = websocket.Upgrader{
	ReadBufferSize:  10240,
	WriteBufferSize: 10240,
	CheckOrigin: func(r *http.Request) bool {
		return true
	},
}
func (r *RecordHandler) Ws(ctx iris.Context) {
  conn, _:= upgrader.Upgrade(ctx.ResponseWriter(), ctx.Request(), nil)
 
go func(){
   err := conn.WriteMessage(websocket.TextMessage,[]byte("ok"))
  //[HTTP Server] http: response.Write on hijacked connection from github.com/kataras/iris/v12/context.(*responseWriter).Write (response_writer.go:276)???
}()
for {
       _, message, err := conn.ReadMessage()
      //close 1006 (abnormal closure): unexpected EOF ????
 }
}

How can I make it work properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants