User Tools

Site Tools




The SocketListener connects to a socket and publishes any incoming data on that socket. When data is received it is transformed to a SIB message and triggers the workflow.




  • Establish connection to the server using and custom.endpoint.port
    • on incoming data:
      • convert buffer to utf8 string
      • add data to SIBMessage
      • apply SIBHeader
      • Publish: .custom.topic
  • Subscribe: .custom.topic/REQUEUE
    • on message:
      • custom.inputFormat
      • Publish: msg._sibheader.topic

Custom configuration

var SocketListenerCustom = {
    _id: "SIBSample:1",
    _name: "My Socket listener",
    endpoint: {
        DEV: { host: "hostname", port: "2000" },
        TEST: { host: "hostname", port: "4000" },
        QA: { host: "hostname", port: "6000" },
        PROD: { host: "hostname", port: "8000" }
    init: ( thisListener )=>{},
    inputFormat: (topic, msg, cb)=>{    
    publishInput: (msg, mqtt)=>{
        mqtt.publish(msg._sibheader.topic, JSON.stringify(msg));
    loggerCfg: {
        dest: {
            file: false,
            console: true,
            mqtt: true
    mqtt: "mqtt://localhost",
    mqtt_timeout: 20000,
    topic: "TOPIC/TO/PUBLISH"
module.exports = SocketListenerCustom;
  • _id: The unique ID of this service
  • _name: A plaintext description of this service
  • Host to connect to
  • endpoint.port: Port on host
  • init(thisListener): If defined this method is executed when the service is starting up as the last step of initialization. thisListener is a reference to the instance of the listener that does the method call.
  • inputFormat(topic, msg, cb): 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
  • mqtt: The MQTT connection string for the internal MQTT transport
  • mqtt_timeout: Number of milliseconds to wait for a response on the MQTT transport before sending a timeout response to the REST Client
  • publishInput: If defined overrides the standard publishing to the internal MQTT transfer
  • topic: The MQTT topic to publish to on the internal MQTT transport
sib/listeners/socketlistener.txt · Last modified: 2019/09/20 07:35 by hubbe