snicker / juicepassproxy

Proxy UDP requests to/from Juicebox EV chargers to MQTT discoverable by Home Assistant
25 stars 8 forks source link

Modify all telnet reads to include a timeout. Propogate timeout setting. #53

Closed j358 closed 2 months ago

j358 commented 3 months ago

Modify all telnet reads to include a timeout. Propogate a timeout setting from entrypoint sh file through juicebox udpc updater class to juicebox telnet class.

snicker commented 3 months ago

@j358 recommend catching the timeout exception explicitly for logging purposes, around line 374

j358 commented 3 months ago

I have added explicit error catching in the latest commit. In addition, I have added error handling to remote data handler and local data handler as I had one instance of an IndexError in local data handler that caused pyproxy to crash. Can split this out as seperate issue if need be.

{"log":"2024-03-30 02:54:00,643 INFO UDPC IP correct\n","stream":"stderr","time":"2024-03-29T14:54:00.643980293Z"} {"log":"Traceback (most recent call last):\n","stream":"stderr","time":"2024-03-29T14:54:25.723272044Z"} {"log":" File \"/juicepassproxy/juicepassproxy.py\", line 672, in \u003cmodule\u003e\n","stream":"stderr","time":"2024-03-29T14:54:25.723424153Z"} {"log":" main()\n","stream":"stderr","time":"2024-03-29T14:54:25.725247011Z"} {"log":" File \"/juicepassproxy/juicepassproxy.py\", line 664, in main\n","stream":"stderr","time":"2024-03-29T14:54:25.725429119Z"} {"log":" pyproxy.udp_proxy(src, dst)\n","stream":"stderr","time":"2024-03-29T14:54:25.727316977Z"} {"log":" File \"/juicepassproxy/pyproxy/pyproxy.py\", line 56, in udp_proxy\n","stream":"stderr","time":"2024-03-29T14:54:25.727719285Z"} {"log":" data = LOCAL_DATA_HANDLER(data)\n","stream":"stderr","time":"2024-03-29T14:54:25.729664419Z"} {"log":" ^^^^^^^^^^^^^^^^^^^^^^^^\n","stream":"stderr","time":"2024-03-29T14:54:25.730012357Z"} {"log":" File \"/juicepassproxy/juicepassproxy.py\", line 307, in local_data_handler\n","stream":"stderr","time":"2024-03-29T14:54:25.730095263Z"} {"log":" message = self.basic_message_try_parse(data)\n","stream":"stderr","time":"2024-03-29T14:54:25.73112632Z"} {"log":" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n","stream":"stderr","time":"2024-03-29T14:54:25.731655219Z"} {"log":" File \"/juicepassproxy/juicepassproxy.py\", line 228, in basic_message_try_parse\n","stream":"stderr","time":"2024-03-29T14:54:25.731737236Z"} {"log":" parts.pop(-1) # Ending blank\n","stream":"stderr","time":"2024-03-29T14:54:25.73257537Z"} {"log":" ^^^^^^^^^^^^^\n","stream":"stderr","time":"2024-03-29T14:54:25.732853884Z"} {"log":"IndexError: pop from empty list\n","stream":"stderr","time":"2024-03-29T14:54:25.732926531Z"} {"log":"2024-03-30 02:54:30,960 INFO UDPC IP correct\n","stream":"stderr","time":"2024-03-29T14:54:30.961300078Z"}

Snuffy2 commented 2 months ago

@snicker, this looks good to go to me.

Snuffy2 commented 2 months ago

UDPC_TIMEOUT and --udpc_timeout should also be added to the ReadMe.

Snuffy2 commented 2 months ago

Merging the PR so it can be tested using Docker edge tag. Will put into release if no issues reported in a few days.