lsongdev / node-bluetooth

:large_blue_diamond:😬Bluetooth serial port communication for Node.js
https://npmjs.org/node-bluetooth
Other
197 stars 56 forks source link

Error: The connection has been closed #35

Closed naxiemolv closed 5 years ago

naxiemolv commented 5 years ago

Thank First

code in example works with Elelctron, but when I shutdown my bluetooth device, it repeats like..........

Error: The connection has been closed
    at read (/Users/project/node_modules/node-bluetooth/lib/connection.js:14:34)
    at process._tickCallback (internal/process/next_tick.js:61:11)
Error: The connection has been closed
    at read (/Users/project/node_modules/node-bluetooth/lib/connection.js:14:34)
    at process._tickCallback (internal/process/next_tick.js:61:11)
Error: The connection has been closed
    at read (/Users/project/node_modules/node-bluetooth/lib/connection.js:14:34)
    at process._tickCallback (internal/process/next_tick.js:61:11)
Error: The connection has been closed
    at read (/Users/project/node_modules/node-bluetooth/lib/connection.js:14:34)
    at process._tickCallback (internal/process/next_tick.js:61:11)
Error: The connection has been closed
    at read (/Users/project/node_modules/node-bluetooth/lib/connection.js:14:34)
    at process._tickCallback (internal/process/next_tick.js:61:11)
Error: The connection has been closed
    at read (/Users/project/node_modules/node-bluetooth/lib/connection.js:14:34)
    at process._tickCallback (internal/process/next_tick.js:61:11)
lsongdev commented 5 years ago

Handle the connection.on("error") events and call connection.close() method.

connection.on("error", err => {
  connection.close();
});