nordicopen / pyeasee

Easee EV charger API python library
MIT License
39 stars 11 forks source link

Error 504 - Gateway time-out #98

Closed hacor closed 2 months ago

hacor commented 3 months ago

Hi all

This way I wanted to ask the question I'm experiencing in my Python app using the pyeasee library. I'm using the library on different locations to dynamically control the Easee Charger. Most of the times this works perfectly, but on one location I get a 504 Gateway Timeo-out on a regularly basis

These are the logs of my python program:

{"dt": "2024-06-04T14:30:38.802710", "level": "INFO", "message": {"module": "easee", "message": "Initializing easee API"}, "thingname": "20231207-hot-parrot"}
{"dt": "2024-06-04T14:30:38.902768", "level": "INFO", "message": {"module": "easee", "message": "Connecting to easee"}, "thingname": "20231207-hot-parrot"}
{"dt": "2024-06-04T14:31:39.276271", "level": "ERROR", "message": {"module": "easee", "error": "Unable to connect to Easee", "error_message": "<html>\r\n<head><title>504 Gateway Time-out</title></head>\r\n<body>\r\n<center><h1>504 Gateway Time-out</h1></center>\r\n</body>\r\n</html>\r\n"}, "thingname": "20231207-hot-parrot"}
{"dt": "2024-06-04T14:32:39.472713", "level": "ERROR", "message": {"module": "easee", "error": "Collecting charger failed", "error_code": "GET_CHARGER_FAILED", "error_message": "<html>\r\n<head><title>504 Gateway Time-out</title></head>\r\n<body>\r\n<center><h1>504 Gateway Time-out</h1></center>\r\n</body>\r\n</html>\r\n"}, "thingname": "20231207-hot-parrot"}

This is the code routine used to connect to the Easee Api. We are using pyeasee==0.7.55

 async def connect_to_easee(self):
      """
      Connect to the easee API
      """

      await self.disconnect()

      if not self.credentials.configured:
          self.logger.warning({
              'module': 'easee',
              'error': 'Credentials are not configured, unable to connect to Easee'
          })
          return

      self.logger.info({
          'module': 'easee',
          'message': 'Initializing easee API'
      })

      self.easee = Easee(username=self.credentials.username,password=self.credentials.password)

      self.logger.info({
          'module': 'easee',
          'message': 'Connecting to easee'
      })
      try:
          await self.easee.connect()

          self.logger.info({
              'module': 'easee',
              'message': 'Connected to easee'
          })
      except Exception as e:
          self.logger.error({
              'module': 'easee',
              'error': 'Unable to connect to Easee',
              'error_message': str(e)                
          })

It seems like a DNS issue, but the device has perfect connection to the internet and I can SSH perfectly so on my side all seems fine. It would be handy if someone could give me some kind of a hint.

Kind regards

Hacor

olalid commented 2 months ago

Hi,

Sorry for not replying earlier, but I have no clue why you get this. The API does sometimes return strange error codes, so that is not new, but seems like you have stumbled on something on the server side that does not work as expected. I would report it to Easee if I were you.

hacor commented 2 months ago

Thanks for your reply @olalid I did got any further in my investigation and it seems the cause was a burst of calls to the Easee API caused by an internal error on my side which made Easee block the concerning API.

I close the issue for now, maybe it can help others debugging the 504 error