wildmountainfarms / solarthing

Monitors an Outback MATE, Renogy Rover - MPPT Charge Controller and EPEver Tracer. Integrates with Grafana, PVOutput and more!
https://solarthing.readthedocs.io
MIT License
130 stars 28 forks source link

CouchDB setup failed #84

Closed rbroen3rd closed 1 year ago

rbroen3rd commented 1 year ago

I started to setup a CouchDB database running on my Mac on the same network as my Pi. Setup the couchdb.json config file as on the website and got the following errors.


rbrown3rd@bobspi01:/opt/solarthing/program/mate$ solarthing run --couchdb-setup config/couchdb.json
16:02:06.194 [main] INFO  m.r.s.p.SolarMain - [LOG] Beginning main. Jar: Jar: solarthing-2023.1.0.jar Last Modified: 2023-01-08T21:59:21Z Java version: 11.0.16
[stdout] Beginning main. Jar: Jar: solarthing-2023.1.0.jar Last Modified: 2023-01-08T21:59:21Z Java version: 11.0.16
[stderr] Beginning main. Jar: Jar: solarthing-2023.1.0.jar Last Modified: 2023-01-08T21:59:21Z Java version: 11.0.16
com.fasterxml.jackson.core.JsonParseException: Unexpected character (':' (code 58)): was expecting comma to separate Object entries
 at [Source: (File); line: 15, column: 20]
    at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:2391)
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:735)
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:659)
    at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:778)
    at com.fasterxml.jackson.databind.util.TokenBuffer._copyBufferContents(TokenBuffer.java:1166)
    at com.fasterxml.jackson.databind.util.TokenBuffer.copyCurrentStructure(TokenBuffer.java:1148)
    at com.fasterxml.jackson.databind.DeserializationContext.bufferAsCopyOfValue(DeserializationContext.java:565)
    at com.fasterxml.jackson.databind.deser.impl.ExternalTypeHandler.handlePropertyValue(ExternalTypeHandler.java:180)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeWithExternalTypeId(BeanDeserializer.java:983)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeWithExternalTypeId(BeanDeserializer.java:948)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeWithExternalTypeId(BeanDeserializer.java:941)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:349)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:184)
    at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4674)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3494)
    at me.retrodaredevil.solarthing.program.SolarMain.doMain(SolarMain.java:217)
    at me.retrodaredevil.solarthing.program.SolarMain.determineMainSubprogram(SolarMain.java:272)
    at me.retrodaredevil.solarthing.program.SolarMain.main(SolarMain.java:286)
Problem reading CouchDB database settings file.```
rbroen3rd commented 1 year ago

Okay. I'm going to focus back on creating a simple database with a design document before I tackle the connectivity problem.

rbroen3rd commented 1 year ago

Created a simple database "koi" and entered a document using cURL. Tried to create a design document with cURL and it failed for the same reason.

curl -X PUT http://admin:xxxxxxx@127.0.0.1:5984/koi/_design/ddoc -d '{"views":{"name":{"map":"function(doc) { emit(doc.name); }"}}}' -H'Content-Type:application/json'
{"error":"error","reason":"internal_server_error"}
retrodaredevil commented 1 year ago

Dang. Well I imagine that error might not appear with a docker install.

If you want to get your existing install to work, you could try looking for errors in couchdb's log file, but I don't know how to find them on a Mac install.

rbroen3rd commented 1 year ago

I'm about to abandon CouchDB and go the docker route.

rbroen3rd commented 1 year ago

Back to basics. Do the Pi and Mac talk to each other at all?

 ping 192.168.1.64
PING 192.168.1.64 (192.168.1.64) 56(84) bytes of data.
64 bytes from 192.168.1.64: icmp_seq=1 ttl=64 time=0.260 ms
64 bytes from 192.168.1.64: icmp_seq=2 ttl=64 time=0.248 ms
64 bytes from 192.168.1.64: icmp_seq=3 ttl=64 time=0.246 ms
64 bytes from 192.168.1.64: icmp_seq=4 ttl=64 time=0.237 ms
64 bytes from 192.168.1.64: icmp_seq=5 ttl=64 time=0.230 ms
64 bytes from 192.168.1.64: icmp_seq=6 ttl=64 time=0.235 ms
64 bytes from 192.168.1.64: icmp_seq=7 ttl=64 time=0.236 ms
64 bytes from 192.168.1.64: icmp_seq=8 ttl=64 time=0.237 ms
64 bytes from 192.168.1.64: icmp_seq=9 ttl=64 time=0.285 ms
^C
--- 192.168.1.64 ping statistics ---
retrodaredevil commented 1 year ago

Can you confirm that running curl http://192.168.1.64:5984 on your pi will give you a response? Can I see your couchdb.json file again? Honestly I would play with the timeout values. Maybe make them bigger or smaller. Note that call_timeout should always be bigger than connection_timeout.

Heck, try not specifying call_timeout and connection_timeout. By not specifying either of those you'll still get sensible defaults. I probably shouldn't have had you change them anyway.

Is your MATE program still uploading data to the database?

Sorry you weren't able to get CouchDB working with a native install. Good luck getting docker and or docker compose working with CouchDB. I can attempt to help out, but there are good docker resources out there for getting set up. It can be a learning curve if you end up going down a rabbit hole trying to understand what docker is and what everything is doing.

rbroen3rd commented 1 year ago

I have a new CouchDB instance installed. I have not been able to connect to it to setup SolarThing databases. I rand the cURL command and got the following:

curl http://192.168.1.64:5984 
curl: (7) Failed to connect to 192.168.1.64 port 5984: Connection refused
rbrown3rd@bobspi01:/opt/solarthing/program/mate$  curl http://192.168.1.64:5984 
rbroen3rd commented 1 year ago

I can ping my Mac from my Pi, so I imagine I have to go through the SolarThing setup again to enable that port? Here is my couchdb.json file:

{
  "type": "couchdb",
  "settings": {
    "packet_upload": {
      "throttle_factor": 3,
      "initial_skip": 1
    },
    "command_download": {
      "throttle_factor": 3,
      "initial_skip": 4
    }
  },
  "config": {
    "protocol": "http",
    "host": "192.168.1.64",
    "port": 5984,
    "username": "admin",
    "password": "xxxxxx",
    "connection_timeout": 5,
    "call_timeout": 10
  }
}
rbroen3rd commented 1 year ago

I notice that users had trouble with creating design documents in older versions of CouchDB. I didn't find any discussion about not being able to do that with newer versions, I'm running version 3.3.1 and have not done a new SolarThing setup on it yet. I created a simple database called Koi with one document in it containing 'name' and 'age' fields. I've not been able to create a design document for that database. That is where all paths seem to end up.

retrodaredevil commented 1 year ago

You should be able to add design documents with views before running SolarThing setup. SolarThing setup doesn't do anything special, it just automates adding the necessary design documents.

I have a new CouchDB instance installed. I have not been able to connect to it to setup SolarThing databases. I rand the cURL command and got the following:

curl http://192.168.1.64:5984 
curl: (7) Failed to connect to 192.168.1.64 port 5984: Connection refused
rbrown3rd@bobspi01:/opt/solarthing/program/mate$  curl http://192.168.1.64:5984 

Alright, before you do anything with SolarThing, that curl command needs to be working. A few things, confirm that really is your Mac's IP address (make sure it stays static too). Also confirm that the bind address is 0.0.0.0 (https://docs.couchdb.org/en/stable/config/http.html#chttpd/bind_address). You can also try running this on your Mac: curl localhost:5984 to confirm that your Mac can see CouchDB.

For your native CouchDB install, I really have no idea how to get adding design documents working, and I don't think I can help you there. I'd be willing do do a tiny bit of research if you pasted your CouchDB logs (from however you are running CouchDB -- I'm not really sure how that works on Mac OS). But really debugging why your CouchDB isn't working isn't really something I want to do.

Also, I edited your password away when you posted your couchdb.json. I assume you weren't using that password for anything critical or you don't care.

rbroen3rd commented 1 year ago

Ran curl on my Mac and got the following.

curl localhost:5984
{"couchdb":"Welcome","version":"3.3.1","git_sha":"1fd50b82a","uuid":"2eb45f12cb039deb09946f59a40532a7","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}

I don't want you to do any research on my CouchDB problem. My immediate monitoring needs beyond importing the serial comma delimited output into a spreadsheet may go away. I had my installer and his engineer look at my fifteen year old Sanyo, now Panasonic, panels and they have suffered some serious degradation. I asked for a proposal from them to make my system whole and to process a warranty claim.

My wish to get SolarThing working on my Pi and CouchDB on my Mac is now just for personal education. If you don't want to take this any farther, I am okay with that. You have provided extraordinary support and I sincerely appreciate that. I just hate being stumped by a problem and while I have not working in IT since 2003, I like keeping my skills up at a minimum level.

retrodaredevil commented 1 year ago

Ran curl on my Mac and got the following.

So that means that the port is not listening on all interfaces and you should look into the bind address to set it to 0.0.0.0 or maybe some sort of firewall (which is unlikely because you had it working before).

I'm happy to help out with any SolarThing related stuff but I think I'm out of suggestions for your CouchDB stuff. Let me know if you need any additional help on the SolarThing side.

You have given me a couple of things to think about for how people want to use SolarThing, so some of these things I may look into in the future:

rbroen3rd commented 1 year ago

Those are good topics to consider. I might suggest a simple log.csv option for those who want an occasional snapshot in a spreadsheet. The process has been fun for me despite the CouchDB frustrations due to some peculiarities of my setup. You have been patient and supportive. Thank you for that. When my installer and his engineer came I had some good data to show them thanks to our efforts to get SolarThing running with CouchDB. Thanks a bunch.