| 883 | */ |
| 884 | /*jshint latedef:false*/ |
| 885 | function handleTLSerrors (err) { |
| 886 | // How can I get verify this error is a tls error? |
| 887 | if (opts.rejectUnauthorized) { |
| 888 | mqttClient.emit('error', err); |
| 889 | } |
| 890 | |
| 891 | // close this connection to match the behaviour of net |
| 892 | // otherwise all we get is an error from the connection |
| 893 | // and close event doesn't fire. This is a work around |
| 894 | // to enable the reconnect code to work the same as with |
| 895 | // net.createConnection |
| 896 | connection.end(); |
| 897 | } |
| 898 | /*jshint latedef:false*/ |
| 899 | |
| 900 | connection.on('error', handleTLSerrors); |