When I create a new session, it writes it to the database, but it gives me an error when I want to use the same session when the server is shut down or restarted.
//custom config for session
var store = session.New(session.Config{
Expiration: 24 * time.Hour,
CookieName: "session_id",
KeyGenerator: func() string {
return "makrube"
},
Storage: postgres.New(postgres.Config{
Host: "localhost",
Port: 5432,
Username: "postgres",
Password: "123",
Database: "blog",
Table: "fiber_storage",
GCInterval: 10 * time.Hour,
}),
})
There is no problem so far.
Session database is written and session is used until the machine is shut down.
Whenever I shut down the machine, the code explodes even though the database has sessionID.
[session] Register this type first with the `RegisterType` method.
panic: reflect: New(nil)
goroutine 66 [running]:
reflect.New(0x0, 0x0, 0x16, 0x16fb1c0, 0xc0002cd120)
C:/Go/src/reflect/value.go:2382 +0xc9
github.com/gofiber/fiber/v2/internal/gotiny.buildDecEngine.func7(0xc0000a1220, 0xc0002cd120)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/gotiny/decEngine.go:188 +0x289
github.com/gofiber/fiber/v2/internal/gotiny.buildDecEngine.func4(0xc0000a1220, 0xc00008b798)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/gotiny/decEngine.go:154 +0x25c
github.com/gofiber/fiber/v2/internal/gotiny.buildDecEngine.func6(0xc0000a1220, 0xc00008b780)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/gotiny/decEngine.go:172 +0x55
github.com/gofiber/fiber/v2/internal/gotiny.buildDecEngine.func1(0xc0000a1220, 0xc000446f88)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/gotiny/decEngine.go:100 +0xa8
github.com/gofiber/fiber/v2/internal/gotiny.(*Decoder).Decode(0xc0000a1220, 0xc000098ee0, 0x19, 0x20, 0xc00045f828, 0x1, 0x1, 0xc00009b6a8)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/gotiny/decoder.go:75 +0x98
github.com/gofiber/fiber/v2/internal/gotiny.Unmarshal(0xc000098ee0, 0x19, 0x20, 0xc00045f828, 0x1, 0x1, 0x0)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/gotiny/decoder.go:19 +0x94
github.com/gofiber/fiber/v2/middleware/session.(*Store).Get(0xc0002b6fc0, 0xc00012e000, 0xc000224000, 0x0, 0x0)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/middleware/session/store.go:62 +0x20b
github.com/omerfruk/my-blog/handlers.LogControl(0xc00012e000, 0x0, 0x0)
C:/Go/src/github.com/omerfruk/my-blog/handlers/researcher.go:124 +0x25a
github.com/gofiber/fiber/v2.(*App).next(0xc00029fcc0, 0xc00012e000, 0xc00009b0b0, 0x1, 0x8)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/router.go:126 +0x1c2
github.com/gofiber/fiber/v2.(*Ctx).Next(0xc00012e000, 0x17c29a9, 0x1b)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/ctx.go:637 +0x92
github.com/gofiber/fiber/v2/middleware/cors.New.func1(0xc00012e000, 0xc00009b098, 0x6)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/middleware/cors/cors.go:141 +0x325
github.com/gofiber/fiber/v2.(*App).next(0xc00029fcc0, 0xc00012e000, 0xc00012e000, 0xf, 0x10)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/router.go:126 +0x1c2
github.com/gofiber/fiber/v2.(*App).handler(0xc00029fcc0, 0xc0002a6000)
C:/Users/omer/go/pkg/mod/github.com/gofiber/fiber/[email protected]/router.go:154 +0x125
github.com/valyala/fasthttp.(*Server).serveConn(0xc0003a0240, 0x1899220, 0xc00050e1b0, 0x0, 0x0)
C:/Users/omer/go/pkg/mod/github.com/valyala/[email protected]/server.go:2193 +0x128c
github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc000246d20, 0xc0002d0060)
C:/Users/omer/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:223 +0xcd
github.com/valyala/fasthttp.(*workerPool).getCh.func1(0xc000246d20, 0xc0002d0060, 0x16cbea0, 0xc0002d0060)
C:/Users/omer/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:195 +0x3c
created by github.com/valyala/fasthttp.(*workerPool).getCh
C:/Users/omer/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:194 +0x115
Process finished with exit code 2