User Tools

Site Tools


sib:listeners:ftplistener

FTPListener

Overview

The FTPListener SIB Listener periodically connects to a configured FTP server and searches for files matching a configured filter. When a file is found it is read and posted to the internal MQTT transport for further handling.

If the delete or moveto .custom configurations are set the handled files are either moved to another path or deleted from the FTP server.

Workflow

  • CRONSchedule: [.custom.schedule]
    • on trigger:
      • Check for files (.custom.path)
        • on file found:
          • Check .custom.filter for filename match
            • on match:
              • Publish: .custom.topic

Custom configuration

ftplistener/custom.js
var FTPListenerCustom = {
	_id: "ftpSample:1",
	_name: "SIB FTPListener Sample",
	delete: true,
	filter: "\.xml$",
	ftp: {
		host: "ftpHost",
		password: "thePass",
		port: 21,
		user: "theUserName"
	},
	inputFormat: (topic, msg, cb)=>{
	cb( msg );
	},
	loggerCfg: {
		dest: {
			file: false,
			console: true,
			mqtt: true
		}
	},
	moveto: "/archive",
	path: "/data",
	schedule: "*/10 * * * * *",
	mqtt: "mqtt://localhost",
	topic: "SIB/Samples/FTPListener"
};
 
module.exports = FTPListenerCustom;
  • _id: The unique ID of this service
  • _name: A plaintext description of this service
  • delete: true/false, if true the file is deleted after pickup
  • filter: RegEx filter to test the filename for, if match the file is picked up
  • ftp:
    • host: The IP or name of the FTP host to connect to
    • password: The password to authenticate the user with
    • port: The port on the host to which to connect
    • user: The user to login as on the server
  • inputFormat(topic, msg, callback): The method that is run on service activation. The original message is passed as the argument and the return value from this method must be a JSON formatted message conforming to the SIB message standard.
  • loggerCfg: A JSON Object defining what logger actions should be active for this service (see Logger Configuration
  • moveto: Where to move the file on the FTP server after pickup
  • path: The file path to check for files
  • publishInput: If defined overrides the standard publishing to the internal MQTT transfer
  • schedule: The cron-schedule when to run the check
  • mqtt: The MQTT connection string for the internal MQTT transport
  • topic: The MQTT topic to subscribe to on the internal MQTT transport
sib/listeners/ftplistener.txt · Last modified: 2019/02/22 15:09 by hubbe