Comments (4)
Hi @KevM - setting PW_POOL_MAXSIZE=1 limits the connection pool size for HTTP persistent connections / re-use to 1. The thinking there "should only be one" connection is a misunderstanding of how this works...
It's due to the fact the pyPowerwall proxy is a multi-threaded HTTP server. For every API request sent by telegraf, a new connection could be opened to the gateway, and telegraf sends multiple requests simultaneously so you will end up with multiple connections due to the multi-threaded nature of the application.
Limiting the pool size to one just means the pool size won't be big enough to serve all the API requests, and you will see pool full warnings, connections discarded and re-opened to serve the request. Setting PW_POOL_MAXSIZE=0 will disable connection pooling and persistent connections, which means a new request to the gateway is opened/closed for every single API request from telegraf (slower, probably adds additional load to the gateway, and guaranteed to not see those warnings if it bothers you).
Persistent connections with the use of a connection pool was implemented to reduce load on the gateway. At least then generally, only e.g. 15x connections would be opened to the gateway. If there were more than 15 simultaneous API requests you will still see pool full warnings though.
There is background on this in issue #20 where I did an analysis of the connection use and benefit of the persistent connections / pool, implemented in PR #21
I'm using the default pool size of 15 and never see any warnings or have performance / drop out issues at all (note - direct ethernet connection to the gateway helps a lot too).
If you really only wanted a single connection from pyPowerwall being used for all API requests to the gateway, then we would need to implement a similar connection use setup that was done for the Cloud mode. Because pyPowerwall is multi-threaded, then this would involve adding locking around API requests to the proxy, so only a single thread would send requests to the gateway - refer #59 (comment)
It's not a bad idea to implement this to be honest... especially if we start seeing issues with the gateway not responding well to having multiple HTTP sessions opened simultaneously (although, I have not seen issues with this so far). It was necessary with the Cloud mode setup due to the cloud limiting connections and often responding with HTTPError: 429 Client Error: Too Many Requests.
from pypowerwall.
Excellent synopsis @mcbirse... 🙏
from pypowerwall.
I've moved away from using PyPowerwall because of this issue. After using a raw connection to the gateway I do not run into any login reconnect issues.
That said I also started using the FleetAPI directly for my needs. The historic precision is limited to 5 minute intervals but this is good enough for my needs. 🤷🏼
from pypowerwall.
Thanks for the follow up @KevM .
from pypowerwall.
Related Issues (20)
- set-reserve ERROR gives Missing access token parameter. Auth token expired? HOT 3
- Ran upgrade.sh but it does not pull all new files HOT 2
- New PW firmware seems to break vitals - 23.44.0 HOT 17
- INFO: Alerts displayed when one Powerwall is defective HOT 1
- Critical Bug - 404 HTTP Status Code Handling
- python3 set-reserve.py --read error HOT 15
- Missing ? energy_sites/grid_import_export HOT 3
- Powerwall not reachable ever since January 26th HOT 1
- Set Reserve via Proxy API HOT 8
- pyPowerwall [0.8.3] Proxy Server [t53] testing HOT 28
- Change the path .auth & .site files are saved to HOT 2
- Slow charge speed from grid? HOT 2
- Cannot set reserve lower than 5% HOT 14
- Changing Battery Configuration State Via GET HOT 2
- PyPowerwall stopped connecting HOT 9
- Issues with POST HOT 3
- Possible FleetAPI bug in __main__.py HOT 1
- Powerwall 3 Local Access via TEDAPI HOT 30
- FleetAPI Setup Bug
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 pypowerwall.