Original post

Hi,
I’m trying to use socket io with go and angular but i have that error
code error

gin.SetMode(gin.ReleaseMode)
router := gin.Default()
//CORS
router.Use(cors.New(cors.Config{
AllowOrigins: []string{“http://localhost:4200”},
AllowMethods: []string{“PUT”, “PATCH”, “POST”, “GET”, “DELETE”},
AllowHeaders: []string{“Origin”, “X-Requested-With”, “Content-Type”, “Cache-
Control”, “Pragma”, “Authorization”, “Accept”, “Accept-Encoding”},
ExposeHeaders: []string{“Content-Length”},
AllowCredentials: true,
// AllowOriginFunc: func(origin string) bool {
// return origin == “*”
// },
MaxAge: 12 * time.Hour,
}))
server, err := socketio.NewServer(nil)
if err != nil {
log.Fatal(err)
}
server.OnConnect(“/”, func(s socketio.Conn) error {
s.SetContext(“”)
fmt.Println(“connected:”, s.ID())
return nil
})
server.OnEvent(“/”, “message”, func(s socketio.Conn, msg string) {
fmt.Println(“notice:”, msg)
s.Emit(“response”, “Nuevo Pedido”)
})
server.OnEvent(“/chat”, “msg”, func(s socketio.Conn, msg string) string {
s.SetContext(msg)
return “recv ” + msg
})
server.OnDisconnect(”/”, func(s socketio.Conn, msg string) {
fmt.Println(“closed”, msg)
server.OnEvent(“/”, “bye”, func(s socketio.Conn) string {
last := s.Context(https://bit.ly/2D5lSqU).(string)
server.OnDisconnect(“/”, func(s socketio.Conn, msg string) {
fmt.Println(“closed”, msg)
s.Emit(“bye”, last)
s.Close()
return last
})
server.OnDisconnect(“/”, func(s socketio.Conn, msg string) {
fmt.Println(“closed”, msg)
})
router.GET(“/socket.io/*any”, gin.WrapH(server))
router.POST(“/socket.io/*any”, gin.WrapH(server))
// router.Handle(“WSS”, “/socket.io”, []gin.HandlerFunc{SocketHandler})
//SERVER PORT
router.Run(“:5000”)