kholbrook1303 / ClimateControl

Climate Control for Raspberry Pi with Grove board
GNU General Public License v3.0
0 stars 0 forks source link

pymongo timeout errors #4

Open GemKosan opened 1 month ago

GemKosan commented 1 month ago

As a Rasp Pi & Grove noob, I'm having trouble getting this project to run without errors. I do have coding experience though not much in Python. Could you provide some advice on this error please? Looks like maybe I need to configure the mongodb, but not sure how to do that. Thanks in advance for your help with this!

CONTEXT

ERROR Stack trace

Please excuse any typos as I'm not able to copy/paste between devices right now:
ERROR Unhandled exception!
Traceback (most recent call last):
  File "..../ClimateControl.py" line 193, in main 
    mphdl.run()
  File "..../ClimateControl.py", line 51, in run 
    self.scd4x.read_wait_scd4x()
  File "..../lib/grove.py", line 153, in read _wait_scd4x 
    while not self.read_scd4x():
                     ^^^^^^^^^^^^^
  File "..../lib/grove.py", line 30 in update_sensor_database 
    mdb.collection.insert_one(data)
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/collection.py", line 658, in insert_one 
    self.insert_one(
    File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/collection.py", line 598, in insert_one 
    self.database.client.retryable_write(
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/mongo_client.py", line 1575, in retryable_write
    return self._retry_with_session(retryable, func, s, buld, operation, operation_id)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/mongo_client.py", line 1461, in _retry_with_session 
    return self._retry_internal(
               ^^^^^^^^^^^^^^^
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/_scot.py", line 108, in csot_wrapper
    return func(self, 'args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/mongo_client.py", line 1507, in _retry_internal).run()
                               ^^^^
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/mongo_client.py", line 2353, in run
    return self.read() if self._is_read else self.write()
                                                                    ^^^^^^^^
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/mongo_client.py", line 2456, in _write
    self.server = self._get_server()
                          ^^^^^^^^^^^^^
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/mongo_client.py", line 2439, in _get_server
    return self._client._select_server(
               ^^^^^^^^^^^^^^^^^^^^
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/mongo_client.py", line 1322, in _select_server
    server = topology.select_server(
                   ^^^^^^^^^^^^^^^^^^
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/topology.py", line 368, in select_server
    server = self._select_server(
                   ^^^^^^^^^^^^^^^
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/topology.py", line  346, in _select_server
    servers = self.select_servers(
                     ^^^^^^^^^^^^^^^
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/topology.py", line 253, in select_servers
    server_descriptions = self._select_servers_loop(
                                          ^^^^^^^^^^^^^^^^^^^^
  File "..../ClimateControl/virtualEnv/lib/python3.11/site-packages/pymongo/topology.py", line 303, in _select_servers_loop
    raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: 192.168.1.100:27017: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30x, Topology Description: <TopologyDescription id: 66ea422dbff829e40ac49cde, topology_type: Unknown, servers: [<ServerDescription ('192.168.1.100', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('192.168.1.100:27017: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>
kholbrook1303 commented 1 month ago

@GemKosan thank you for your interest in this project! The problem is that Mongo was partially implemented as I worked to create a WebUI to track the environmental variables. I should not have added that to the production branch. I have decided that due to Mongo RPi install issues/complexities, I would revert to sqlite for database transactions.

I have updated the code here in git so if you wouldn't mind please repull the code and test once more to see if you have any issues.

The readme was put together somewhat haphazardly so if there are opportunities to enhance it I can most certainly do that.

I'll leave this open pending confirmation.

GemKosan commented 1 month ago

@kholbrook1303 Hmmm... I'm still getting that same pymongo ServerSelectionTimeoutError. I did a fresh install of Dexter's Rasperian for Robots and a fresh clone of this repo. I even did a git pull and was told I'm already up to date. Maybe I'm pulling from the wrong branch or commit. My git skills are kinda rusty.

PS: I've been using pip3 and Python 3. Should I be using pip and Python 2?

kholbrook1303 commented 1 month ago

@GemKosan I was able to reproduce what you were seeing. That was strange indeed. I went ahead and redid the commit and push so it should now be good. You can either reclone or in the directory you cloned just run git pull and it should update removing the old MongoDB code.

GemKosan commented 1 month ago

@kholbrook1303 Thanks for your help. I was able to get it up and running after messing with my dependencies a bit. Just FYI, I was using the latest Rasperian from Dexter Industries, and I had to run their update_grovepi bash script, then pip install smbus and certifi, also uninstall the pip version of numpy as it was conflicting with the globally installed version.

I'm going to play around a bit with the config and look at the code now. This weekend, I intend to hook this up to a mushroom grow box with a humidifier, fan, and lamp.

PS: I might eventually try again to get the dependencies working to run on the latest Raspberry Pi OS instead of the Dexter version, cuz that one seems old, and I can't update apt on it. Which version of the OS are you using?