Comments (5)
Please explain the conditions under which automatic reconnection is useful. I don't think under an error condition it would be useful.
from pigpio-client.
yes in case of error or if you can not connect to the server you will need to try again
from pigpio-client.
I suppose I could implement using the reconnector npm package. If so, what should be used for startTimeout
endTimeout
maxTimes
?
I just haven't had the need for this so I need some guidance on the use case. Thanks.
from pigpio-client.
@bulentkusva
I have created a branch in this repo called 'autoreconnect'. It will solve 3 cases that I consider important or that I have recently run into:
-
After initial creation of pigpio-client object, if not successfully connected, automatically reconnect if any error occurs. Likely errors encountered are
ECONNREFUSED
orEHOSTUNREACH
when the remote pigpiod process or host is not available. This case is currently covered and has been tested somewhat. -
After pigpio-client is connected, if a socket receives an error or is forcibly closed, then destroy current connections, emit
'disconnected'
event to application and wait forpigpio-client.connect()
to reestablish connections. The code covers this case and I have successfully completed a preliminary test. -
Detect a dead peer on notification socket using built-in pigpio keep alive packet. This covers the case when the remote host running pigpiod is unexpectedly reset - say due to a power loss - and comes back up without connections, yet pigpio-client still has open connections (ie no errors have occurred). The code for this case is not yet written. I'm currently working on it.
Cases 2 and 3, require a change to your application. You must monitor for 'disconnected' event and call connect()
method after any housekeeping. You'll need to re-initialize pigpio as the state of pins, pwm, alerts, etc have all been reset. In my app, I just called my init()
function after attaching a one time listener to the new 'connected'
event. Like so:
// on disconnect re-initialize pigpio
pigpio.on('disconnected', (reason) => {
console.log('rcencoder: received disconnect event')
console.log('rcencoder: re-initializing pigpio')
pigpio.connect()
pigpio.once('connected', () => { init()})
})
from pigpio-client.
Case 3 (dead connection) is now covered and tested (one time) successfully. After I complete more testing I'll merge this branch into master. Release to NPM as v1.1.0?
from pigpio-client.
Related Issues (20)
- Process exits silently ... HOT 1
- Make hardware PWM work HOT 1
- Network error not handled HOT 55
- Error using waveform HOT 11
- I2C support HOT 24
- lower timeout - for connection monitor HOT 2
- AssertionError [ERR_ASSERTION]: Argument 'gpio' is not a user GPIO. HOT 7
- Notifications not working after network disconnect then reconnect. HOT 21
- can't set up pulldown resistor HOT 8
- make install error HOT 1
- Latest Installation Unit File In Git Is Wrong HOT 3
- SPI functionality HOT 10
- gpio.waveAddSerial() only supports 1 stop bit.
- Notify on only one edge HOT 10
- Can't use more than 11 pigpio.gpio() HOT 5
- Timing issues with pigpio-client HOT 1
- Correct way to destroy the instance? HOT 1
- writing and running pigpiod scripts? HOT 4
- i2c full features HOT 2
- timeout on first connect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pigpio-client.