diff --git a/src/ApiGatewayWebSocket.js b/src/ApiGatewayWebSocket.js index efd67b896..9a329dc21 100644 --- a/src/ApiGatewayWebSocket.js +++ b/src/ApiGatewayWebSocket.js @@ -98,6 +98,11 @@ module.exports = class ApiGatewayWebSocket { ws.send(JSON.stringify({ message:'Internal server error', connectionId, requestId:'1234567890' })); } + // mimic AWS behaviour (close connection) when the $connect action handler throws + if (name === '$connect') { + ws.close(); + } + debugLog(`Error in handler of action ${action}`, err); };