Skip to content

Commit

Permalink
Merge pull request #264 from pixlise/bugfix/autoquant
Browse files Browse the repository at this point in the history
Attempting to get aws load balancer to play nicer with our web sockets
  • Loading branch information
pnemere authored Jul 5, 2024
2 parents 59dce58 + 21ba50d commit 54a944c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api/router/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/http"

"github.com/pixlise/core/v4/api/services"
"github.com/pixlise/core/v4/core/errorwithstatus"
"github.com/pixlise/core/v4/core/jwtparser"
)

Expand All @@ -45,6 +46,8 @@ func (h ApiHandlerGeneric) ServeHTTP(w http.ResponseWriter, r *http.Request) {
userInfo, err := h.APIServices.JWTReader.GetUserInfo(r)
if err == nil {
err = h.Handler(ApiHandlerGenericParams{h.APIServices, userInfo, pathParams, w, r})
} else {
err = errorwithstatus.MakeBadRequestError(err)
}

if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion api/ws/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
apiRouter "github.com/pixlise/core/v4/api/router"
"github.com/pixlise/core/v4/api/services"
"github.com/pixlise/core/v4/api/ws/wsHelpers"
"github.com/pixlise/core/v4/core/errorwithstatus"
"github.com/pixlise/core/v4/core/jwtparser"
"github.com/pixlise/core/v4/core/utils"
protos "github.com/pixlise/core/v4/generated-protos"
Expand Down Expand Up @@ -64,7 +65,12 @@ func (ws *WSHandler) HandleBeginWSConnection(params apiRouter.ApiHandlerGenericP
}

func (ws *WSHandler) HandleSocketCreation(params apiRouter.ApiHandlerGenericPublicParams) error {
ws.melody.HandleRequest(params.Writer, params.Request)
if err := ws.melody.HandleRequest(params.Writer, params.Request); err != nil {
// Added to help debug load balancer behaviour
fmt.Printf("HandleSocketCreation BadRequest error=\"%v\" from host: %v, method: %v, url: %v, agent: %v\n", err, params.Request.Host, params.Request.Method, params.Request.URL, params.Request.UserAgent())
return errorwithstatus.MakeBadRequestError(err)
}

return nil
}

Expand Down

0 comments on commit 54a944c

Please sign in to comment.