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

[BUG] how to recover program #78

Open
Karrrrrrrr opened this issue Jan 7, 2023 · 0 comments
Open

[BUG] how to recover program #78

Karrrrrrrr opened this issue Jan 7, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Karrrrrrrr
Copy link

if I have some runtime error in hooks(OnConnect function or any other), this program will abort
so how to save program not abort

package main

import (
	"github.com/gin-gonic/gin"
	"github.com/gorilla/websocket"
	"github.com/kataras/neffos"
	"github.com/kataras/neffos/gorilla"
	"net/http"
)

const (
	namespace = "default"
	timeout   = 0 // 30 * time.Second
)

var handler = neffos.WithTimeout{
	ReadTimeout:  timeout,
	WriteTimeout: timeout,
	Namespaces: neffos.Namespaces{
		namespace: neffos.Events{},
	},
}

func main() {
	upgrader := gorilla.Upgrader(websocket.Upgrader{CheckOrigin: func(r *http.Request) bool {
		return true
	}})
	server(upgrader)
}

func server(upgrader neffos.Upgrader) {
	srv := neffos.New(upgrader, handler)

	srv.OnConnect = func(c *neffos.Conn) error {
		var i *int
		*i = 1
		// this process will abort at this
		// so how to continue and recover process
		return nil
	}

	app := gin.New()

	app.GET("/echo", gin.WrapH(srv))

	app.Run()

}
@Karrrrrrrr Karrrrrrrr added the bug Something isn't working label Jan 7, 2023
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