Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker st2chatops will not start rocketchat adapter #167

Open
MrDiba opened this issue Jul 19, 2021 · 8 comments
Open

Docker st2chatops will not start rocketchat adapter #167

MrDiba opened this issue Jul 19, 2021 · 8 comments

Comments

@MrDiba
Copy link
Contributor

MrDiba commented Jul 19, 2021

When I try to use the st2chatops docker container configured for using Rocket Chat the container will give an error that it can't find ddp.js and exits.

st2chatops log:

st2api is ready, starting hubot...
Testing hubot configuration...
Mon, 19 Jul 2021 11:56:11 GMT body-parser deprecated undefined extended: provide extended option at node_modules/hubot/src/robot.js:445:21
[Mon Jul 19 2021 13:56:11 GMT+0200 (Central European Summer Time)] DEBUG Loading adapter rocketchat
[Mon Jul 19 2021 13:56:11 GMT+0200 (Central European Summer Time)] ERROR Cannot load adapter rocketchat - Error: Cannot find module 'ddp.js'
Require stack:
- /opt/stackstorm/chatops/node_modules/@rocket.chat/sdk/node_modules/asteroid/dist/asteroid.node.js
- /opt/stackstorm/chatops/node_modules/@rocket.chat/sdk/dist/lib/driver.js
- /opt/stackstorm/chatops/node_modules/@rocket.chat/sdk/dist/index.js
- /opt/stackstorm/chatops/node_modules/hubot-rocketchat/index.js
- /opt/stackstorm/chatops/node_modules/hubot/src/robot.js
- /opt/stackstorm/chatops/node_modules/hubot/es2015.js
- /opt/stackstorm/chatops/node_modules/hubot/index.js
- /opt/stackstorm/chatops/node_modules/hubot/bin/hubot.js
- /opt/stackstorm/chatops/node_modules/hubot/bin/hubot
WARNING: hubot --config-check failed, are your adapter variables configured properly?

.env configuration:

T2_VERSION=3
ST2_CHATOPS_ENABLE=1
ST2_API_KEY=<generated api key>
TZ=Europe/Amsterdam
######################################################################
# Chat service adapter settings

# RocketChat settings (https://github.com/RocketChat/hubot-rocketchat):
#
HUBOT_ADAPTER=rocketchat
ROCKETCHAT_URL=<rocketchat url>
ROCKETCHAT_USER=<bot name>
ROCKETCHAT_PASSWORD=<bot password>
ROCKETCHAT_ROOM=<default room>

docker-compose.yml from https://github.com/stackstorm/st2-docker

...
  st2chatops:
    image: ${ST2_IMAGE_REPO:-stackstorm/}st2chatops:${ST2_VERSION:-latest}
    restart: on-failure:5
    depends_on:
      - st2api
      - st2auth
      - st2stream
    command: /st2chatops-startup.sh
    networks:
      - private
    environment:
      ST2_AUTH_URL: ${ST2_AUTH_URL:-http://st2auth:9100/}
      ST2_API_URL: ${ST2_API_URL:-http://st2api:9101/}
      ST2_STREAM_URL: ${ST2_STREAM_URL:-http://st2stream:9102/}
      ST2_API_KEY: ${ST2_API_KEY:-change-to-your-st2-api-key}
      TZ: ${TZ:-UTC}
      # enable chatops by setting this variable to any non-zero value
      # and enable/set your hubot adapter specific variables below
      ST2_CHATOPS_ENABLE: ${ST2_CHATOPS_ENABLE:-0}
      # Custom hubot adapter ENV variables to pass through which will override st2chatops.env defaults.
      # See https://github.com/StackStorm/st2chatops/blob/master/st2chatops.env
      # for the full list of supported adapters and example ENV variables.
      HUBOT_ADAPTER: ${HUBOT_ADAPTER:-slack}
      HUBOT_LOG_LEVEL: ${HUBOT_LOG_LEVEL:-debug}
      HUBOT_SLACK_TOKEN: ${HUBOT_SLACK_TOKEN:-}
    volumes:
      - ./scripts/st2chatops-startup.sh:/st2chatops-startup.sh
    dns_search: .
...

How can I solve this issue?

@MrDiba
Copy link
Contributor Author

MrDiba commented Jul 22, 2021

It looks like this is not a Docker specific problem; I installed Stackstorm on a clean ubuntu 20.04.2 LTS vm using the quick install script.

using the same configuration in /opt/stackstorm/chatops/st2chatops.env :

HUBOT_ADAPTER=rocketchat
ROCKETCHAT_URL=<rocketchat url>
ROCKETCHAT_USER=<bot name>
ROCKETCHAT_PASSWORD=<bot password>
ROCKETCHAT_ROOM=<default room>

A tail on /var/log/syslog reveals the following error in a loop:

Jul 22 09:07:28 stackstorm systemd[1]: Started StackStorm service st2chatops.
Jul 22 09:07:28 stackstorm hubot[44063]: Thu, 22 Jul 2021 09:07:28 GMT body-parser deprecated undefined extended: provide extended option at node_modules/hubot/src/robot.js:445:21
Jul 22 09:07:28 stackstorm hubot[44063]: [Thu Jul 22 2021 09:07:28 GMT+0000 (Coordinated Universal Time)] DEBUG Loading adapter rocketchat
Jul 22 09:07:28 stackstorm hubot[44063]: [Thu Jul 22 2021 09:07:28 GMT+0000 (Coordinated Universal Time)] ERROR Cannot load adapter rocketchat - Error: Cannot find module 'ddp.js'
Jul 22 09:07:28 stackstorm hubot[44063]: Require stack:
Jul 22 09:07:28 stackstorm hubot[44063]: - /opt/stackstorm/chatops/node_modules/@rocket.chat/sdk/node_modules/asteroid/dist/asteroid.node.js
Jul 22 09:07:28 stackstorm hubot[44063]: - /opt/stackstorm/chatops/node_modules/@rocket.chat/sdk/dist/lib/driver.js
Jul 22 09:07:28 stackstorm hubot[44063]: - /opt/stackstorm/chatops/node_modules/@rocket.chat/sdk/dist/index.js
Jul 22 09:07:28 stackstorm hubot[44063]: - /opt/stackstorm/chatops/node_modules/hubot-rocketchat/index.js
Jul 22 09:07:28 stackstorm hubot[44063]: - /opt/stackstorm/chatops/node_modules/hubot/src/robot.js
Jul 22 09:07:28 stackstorm hubot[44063]: - /opt/stackstorm/chatops/node_modules/hubot/es2015.js
Jul 22 09:07:28 stackstorm hubot[44063]: - /opt/stackstorm/chatops/node_modules/hubot/index.js
Jul 22 09:07:28 stackstorm hubot[44063]: - /opt/stackstorm/chatops/node_modules/hubot/bin/hubot.js
Jul 22 09:07:28 stackstorm hubot[44063]: - /opt/stackstorm/chatops/node_modules/hubot/bin/hubot
Jul 22 09:07:28 stackstorm systemd[1]: st2chatops.service: Main process exited, code=exited, status=1/FAILURE
Jul 22 09:07:28 stackstorm systemd[1]: st2chatops.service: Failed with result 'exit-code'.
Jul 22 09:07:33 stackstorm systemd[1]: st2chatops.service: Scheduled restart job, restart counter is at 1037.
Jul 22 09:07:33 stackstorm systemd[1]: Stopped StackStorm service st2chatops.

@arm4b
Copy link
Member

arm4b commented Jul 25, 2021

Thanks for the report @MrDiba.
Can you please check what nodejs version do you have installed?

Try to verify installing previous stackstorm version and see if error persist.
In latest st2 v3.5.0 we switched to newer nodejs version.

You can try installing an older st2 v3.4.1 from scratch on a clean VM:

bash <(curl -sSL https://stackstorm.com/packages/install.sh) --user=st2admin --password=Ch@ngeMe --version=3.4.1

Let us know if the error persist in the previous st2chatops version or it's really a new regression.

@MrDiba
Copy link
Contributor Author

MrDiba commented Jul 27, 2021

Hi @armab, thank you for your response. I have checked the nodejs version on the v3.5.0 install and it is v14.17.2

After installing a clean Ubuntu 18.04LTS and installing st2 v3.4.1 the rocketchat adapter will start and load. But I'm running into an issue that it can not connect to my rocket chat instance and time-outs. I do not think this is an problem related to the above issue and will try to get it working.

Jul 27 08:57:20 stackstorm2 systemd[1]: Started StackStorm service st2chatops.
Jul 27 08:57:20 stackstorm2 hubot[19569]: Tue, 27 Jul 2021 08:57:20 GMT body-parser deprecated undefined extended: provide extended option at node_modules/hubot/src/robot.js:445:21
Jul 27 08:57:20 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:20 GMT+0000 (Coordinated Universal Time)] DEBUG Loading adapter rocketchat
Jul 27 08:57:20 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:20 GMT+0000 (Coordinated Universal Time)] INFO [startup] Rocket.Chat adapter in use
Jul 27 08:57:20 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:20 GMT+0000 (Coordinated Universal Time)] INFO [startup] Respond to the name: hubot
Jul 27 08:57:20 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:20 GMT+0000 (Coordinated Universal Time)] INFO I will also respond to my Rocket.Chat username as an alias !
Jul 27 08:57:20 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:20 GMT+0000 (Coordinated Universal Time)] INFO [startup] Rooms specified: <room name>
Jul 27 08:57:20 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:20 GMT+0000 (Coordinated Universal Time)] INFO [connect] Connecting { host: '<rocketchat url>', useSsl: false, timeout: 20000 }
Jul 27 08:57:40 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:40 GMT+0000 (Coordinated Universal Time)] INFO [connect] Timeout (20000)
Jul 27 08:57:40 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:40 GMT+0000 (Coordinated Universal Time)] ERROR Unable to connect: {}
Jul 27 08:57:40 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:40 GMT+0000 (Coordinated Universal Time)] ERROR undefined
Jul 27 08:57:40 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:40 GMT+0000 (Coordinated Universal Time)] ERROR Unable to login: {}
Jul 27 08:57:40 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:40 GMT+0000 (Coordinated Universal Time)] ERROR undefined
Jul 27 08:57:40 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:40 GMT+0000 (Coordinated Universal Time)] ERROR Unable to join rooms: {}
Jul 27 08:57:40 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:40 GMT+0000 (Coordinated Universal Time)] ERROR undefined
Jul 27 08:57:40 stackstorm2 hubot[19569]: [Tue Jul 27 2021 08:57:40 GMT+0000 (Coordinated Universal Time)] ERROR Unable to subscribe {}
Jul 27 08:57:40 stackstorm2 hubot[19569]: (node:19569) UnhandledPromiseRejectionWarning: Error: Asteroid connection timeout
Jul 27 08:57:40 stackstorm2 hubot[19569]:     at Timeout._onTimeout (/opt/stackstorm/chatops/node_modules/@rocket.chat/sdk/dist/lib/driver.js:130:25)
Jul 27 08:57:40 stackstorm2 hubot[19569]:     at ontimeout (timers.js:436:11)
Jul 27 08:57:40 stackstorm2 hubot[19569]:     at tryOnTimeout (timers.js:300:5)
Jul 27 08:57:40 stackstorm2 hubot[19569]:     at listOnTimeout (timers.js:263:5)
Jul 27 08:57:40 stackstorm2 hubot[19569]:     at Timer.processTimers (timers.js:223:10)
Jul 27 08:57:40 stackstorm2 hubot[19569]: (node:19569) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Jul 27 08:57:40 stackstorm2 hubot[19569]: (node:19569) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I also tried to use the v3.4.1 docker release but it looks like that one has no st2chatops included with it?

@MrDiba
Copy link
Contributor Author

MrDiba commented Jul 27, 2021

Can confirm that the time-out problem is not related to to the original issue.

The reason it could not connect is because it tried to connect without SSL when the rocketchat server requires a SSL connection.
Thanks to this topic: RocketChat/hubot-rocketchat#95 it suggested to add export ROCKETCHAT_USESSL=true to the st2chatops.env and that did the trick.

@arm4b
Copy link
Member

arm4b commented Jul 27, 2021

Thanks @MrDiba for the contribution, I've merged your Pull Request.

So looks like st2chatops v3.4.1 works properly with RocketChat,
but there's still a regression in v3.5.0 per first message?

ERROR Cannot load adapter rocketchat - Error: Cannot find module 'ddp.js'

@MrDiba
Copy link
Contributor Author

MrDiba commented Jul 27, 2021

That is correct @armab

@arm4b
Copy link
Member

arm4b commented Jul 27, 2021

Thanks for confirming!

In a meantime, you can use the st2-docker repository with docker-compose https://github.com/StackStorm/st2-docker/blob/master/docker-compose.yml#L224 from the master branch.

Just pin the st2docker image version to v3.4.1 in there, while keeping the stackstorm running on the v3.5.0. They're compatible.

@pvyaka01
Copy link

pvyaka01 commented Apr 5, 2022

I'm trying to use StackStorm latest version (3.6) with rocketchat and chatops 3.4.1. It connects, responds to commands but chatops.post_message, although it says it's successful, doesn't post anything back to rocketchat. Is there a different version of stackstorm I should use? I tried with both docker and VM install with same results.

@cognifloyd cognifloyd removed this from To Do in StackStorm v3.6.0 Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants