             let service = NetService(domain: domain, type: type , name: name, port: Int32(port))
             nsp = service
             service.delegate = self
-            service.setTXTRecord(NetService.data(fromTXTRecord: txtRecord))
+            
+            if let record = txtRecord {
+                if record.count > 0 {
+                    service.setTXTRecord(NetService.data(fromTXTRecord: record))
+                }
+            }
             
             commandDelegate?.run(inBackground: {
                 service.publish()

            print("ZeroConf: register \(type + domain + "@@@" + name)")
        #endif
        
        var txtRecord: [String: Data] = [:]
        if let dict = command.arguments[4] as? [String: String] {
            for (key, value) in dict {
                txtRecord[key] = value.data(using: String.Encoding.utf8)
            }
        }
        

        var type: String
        var name: String
        var port: Int
        var txtRecord: [String: Data]?
        var callbackId: String
        var commandDelegate: CDVCommandDelegate?
        
        init (withDomain domain: String, withType type: String, withName name: String, withPort port: Int, withTxtRecord txtRecord: [String: Data]?, withCallbackId callbackId: String) {
            self.domain = domain
            self.type = type
            self.name = name
