lucacalcaterra / risco-mqtt-bridge

Risco Alarm panel to MQTT Server Bridge
MIT License
25 stars 9 forks source link

Cannot connect to the cloud #60

Open neveride84 opened 6 months ago

neveride84 commented 6 months ago

Every 10 second it tries to connect to the cloud, but can't:

... 10-04-2024 07:07:25 warn: Disconnected from cloud...relogin and init... 10-04-2024 07:07:35 warn: Disconnected from cloud...relogin and init... 10-04-2024 07:07:45 warn: Disconnected from cloud...relogin and init... 10-04-2024 07:07:55 warn: Disconnected from cloud...relogin and init... 10-04-2024 07:08:05 warn: Disconnected from cloud...relogin and init... 10-04-2024 07:08:15 warn: Disconnected from cloud...relogin and init... ...

It's a fresh installation, but I am sure the credentials are fine, because when I provide wrong credentials I get different log:

09-04-2024 17:26:28 warn: Disconnected from cloud...relogin and init... 09-04-2024 17:26:28 error: Exceptions on login response: AxiosError: Request failed with status code 200

If that can't be fixed (not maintained anymore or any other reason), could someone confirm they experience the same or that maybe it's working for them? I will appreciate it!

I am using the docker version on QNAP if that's important.

lucacalcaterra commented 5 months ago

Hi, here's the author. The project is not actively maintained but should not cause these issues. Can you give me region and how many parts do you have ? I'm currently up it on a docker without issues.

neveride84 commented 5 months ago

Hi, thanks for responding. I am from Poland. This is my config.js:

exports.Conn = {
  // Login Data... TYPE THIS AT YOUR OWN RISK!
  loginData: {
    username: 'USERNAME', // your Risco Panel username
    password: 'PASSWORD', // your Risco Panel password
    code: 'CODE', // your Risco Panel code
    iSelectedSiteId: 'SITE_ID',
  },
  RISCOHOST: 'https://www.riscocloud.com/',
  ENDPOINT: 'ELAS/WebUI/',
  ResURLs: {
    LOGIN: '',
    SITELOGIN: 'SiteLogin',
    GETCAMS: 'Cameras/Get',
    GETDECTS: 'Detectors/Get',
    GETEH: 'EventHistory/Get',
    GETOV: 'Overview/Get',
    GETCPSTATE: 'Security/GetCPState',
    SETARMDISARM: 'Security/ArmDisarm',
    SETDETBYPASS: 'Detectors/SetBypass',
    ISUSERCODEEXPIRED: 'SystemSettings/IsUserCodeExpired',
  },
  ResCODES: {
    RESP200: 200,
    RESP302: 302,
  },
  postRequestOptions: {
    referer: 'MainPage/MainPage',
  },
  POLLINGINTERVAL: 10000,
  CYCLEBEFOREUSERALIVE: 30,
  USERISALIVE: '?userIsAlive=true',
};

exports.States = {
  armStatus: {
    ARMED: 'armed',
    PARTARMED: 'partarmed',
    DISARMED: 'disarmed',
    ONALARM: 'onalarm',
  },
  armCommands: {
    ARM: 'armed',
    DISARM: 'disarmed',
    PARTARM: 'partially',
  },
};

exports.Mqtt = {
  url: {
    MQTT_SERVER: 'mqtt.local', // your Mqtt Server address
    MQTT_PORT: 1883, // Mqtt default port
  },
  options: {
    username: '', // Mqtt Server username (if required)
    password: '', // Mqtt Server password (if required)
  },
  msgOptions: {
    clientId: 'mqttjs_Risco',
    retain: true,

  },
  channels: {
    MAINCHAN: 'riscopanel', // Main Topic
    ARMSTATUS: 'armstatus', // Arm status subtopic
    DETECTORS: 'dects', // Detectors subtopic
    EVENTHISTORY: 'eventhistory', // Event History subtopic
    ISONALARM: 'isonalarm', // Topic for receiving ongoing alarm
  },
  transforms: {
    // transforms states strings...to use for example in Home Assistant to reflect H.A.'s  alarm control panel states
    states: {
      disarmed: 'disarmed', // disarmed
      partarmed: 'partarmed', // If you use Home Assistant you must set to 'armed_home'
      armed: 'armed', // If you use  Home Assistant you must set to 'armed_away'
      onalarm: 'onalarm', // If you use  Home Assistant you must set to 'triggered'
    },
  },
};

The username, password, code and site ID are correct. I have no clue what may be causing it. Once or twice a day I see this in the logs (probably connection issues at those particular times):


16-04-2024 05:09:14 warn: Disconnected from cloud...relogin and init...
16-04-2024 05:09:14 error: Exceptions on login response: Error: connect ENETUNREACH 51.124.48.37:443
16-04-2024 05:09:14 error: Exception after sending code: Error: connect ENETUNREACH 51.124.48.37:443

If I provide a wrong password I see this:

16-04-2024 10:08:38 error: Exceptions on login response: AxiosError: Request failed with status code 200
16-04-2024 10:08:49 warn: Disconnected from cloud...relogin and init...
16-04-2024 10:08:49 error: Exceptions on login response: AxiosError: Request failed with status code 200
16-04-2024 10:08:59 warn: Disconnected from cloud...relogin and init...
16-04-2024 10:08:59 error: Exceptions on login response: AxiosError: Request failed with status code 200
16-04-2024 10:09:09 warn: Disconnected from cloud...relogin and init...

I am certain that the logging in process is executed properly, because providing a wrong password locks my account for 5 minutes and I cannot access Risco cloud using my web browser. However when I provide the correct credentials in config.js, then the logs show up as:

16-04-2024 09:44:59 warn: Disconnected from cloud...relogin and init...
16-04-2024 09:45:09 warn: Disconnected from cloud...relogin and init...
16-04-2024 09:45:19 warn: Disconnected from cloud...relogin and init...
16-04-2024 09:45:30 warn: Disconnected from cloud...relogin and init...
16-04-2024 09:45:40 warn: Disconnected from cloud...relogin and init...
16-04-2024 09:45:50 warn: Disconnected from cloud...relogin and init...
16-04-2024 09:46:00 warn: Disconnected from cloud...relogin and init...
16-04-2024 09:46:10 warn: Disconnected from cloud...relogin and init...

I do not see anything being pushed to my MQTT server.

lucacalcaterra commented 5 months ago

@neveride84 probably an ipv6 related issue. try to disable. Try with latest docker image (built today) too...

neveride84 commented 5 months ago

I disabled ipv6. I reinstalled the container from the latest image you created. Nothing has changed. I see that when the container starts, there is this in the logs:

18-04-2024 11:08:07 info: Express server started...
18-04-2024 11:08:10 error: error! Cannot connect to MQTT Server... Server is offline... stopping poll...
18-04-2024 11:08:36 info: Connected to MQTT Server
18-04-2024 11:08:47 warn: Disconnected from cloud...relogin and init...

Not sure why it cannot connect to the MQTT server the first time it tries. I put the IP address in the config file instead of the hostname, thinking that the DNS could be a culprit. Unfortunately it's not that.

So I still cannot get it to work and I am out of ideas. If you are out of ideas too, then feel free to close the issue. If it's working for you then the problem is probably somehwere in my setup. No idea where though...

Thanks again for responding!