Skip to content
Snippets Groups Projects
Unverified Commit ba51baf1 authored by Casey Kuhlman's avatar Casey Kuhlman Committed by GitHub
Browse files

Merge pull request #717 from silasdavis/fix-websocket-panic

Protect against panics in websocket process
parents d4d13a06 d65d7544
No related branches found
No related tags found
No related merge requests found
......@@ -141,7 +141,7 @@ test: check
.PHONY: test_integration
test_integration:
@go get -u github.com/monax/keys/cmd/monax-keys
@go get -u github.com/monax/bosmarmot/keys/cmd/monax-keys
@go test ./keys/integration -tags integration
@go test ./rpc/tm/integration -tags integration
......
......@@ -21,6 +21,7 @@ import (
"github.com/hyperledger/burrow/event"
"github.com/hyperledger/burrow/logging"
"github.com/hyperledger/burrow/logging/structure"
logging_types "github.com/hyperledger/burrow/logging/types"
"github.com/hyperledger/burrow/rpc"
"github.com/hyperledger/burrow/rpc/v0/server"
......@@ -51,6 +52,15 @@ func NewWebsocketService(codec rpc.Codec, service rpc.Service, logger logging_ty
// Process a request.
func (ws *WebsocketService) Process(msg []byte, session *server.WSSession) {
defer func() {
if r := recover(); r != nil {
err := fmt.Errorf("panic in WebsocketService.Process(): %v", r)
logging.InfoMsg(ws.logger, "Panic in WebsocketService.Process()", structure.ErrorKey, err)
if !session.Closed() {
ws.writeError(err.Error(), "", rpc.INTERNAL_ERROR, session)
}
}
}()
// Create new request object and unmarshal.
req := &rpc.RPCRequest{}
errU := json.Unmarshal(msg, req)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment