       return @sendError error.message, event.data if error?
 
       @rateLimit @socket.id, type, (error) =>
-        return @sendError error.message, event.data, 429 if error?
+        return @closeWithError error, [type,data], 429 if error?
         return @emit type, data if type == 'identity'
 
         @authDevice @uuid, @token, (error, authedDevice)=>

  onSocketData: (data) =>
    @sendFrame 'data', data

module.exports = MeshbluWebsocketHandler

          @authedDevice = authedDevice

          @emit type, data

  closeWithError: (error, frame, code) =>
    @sendError error.message, frame, 429
    @socket.close 429, error.message

  # message handlers
  device: (data) =>
