Rocket.Chat.js.SDK icon indicating copy to clipboard operation
Rocket.Chat.js.SDK copied to clipboard

Creating bot

Open JerryBerry12 opened this issue 1 year ago • 6 comments

Hi, I tried creating a bot with the tutorial at: https://developer.rocket.chat/bots/creating-your-own-bot-from-scratch/develop-a-rocket.chat-sdk-bot. The bot keeps trying to connect, and it produces this:

[connect] Connecting {
  username: 'bot',
  password: 'pass',
  ldap: false,
  host: 'localhost',
  useSsl: 'false',
  timeout: 20000,
  rooms: [],
  allPublic: false,
  dm: false,
  livechat: false,
  edited: false,
  integrationId: 'js.SDK',
  roomCacheMaxSize: 10,
  roomCacheMaxAge: 300000,
  dmCacheMaxSize: 10,
  dmCacheMaxAge: 100000
}
[connect] Timeout (20000)
/home/jerryberry12/hopebot/node_modules/@rocket.chat/sdk/dist/lib/driver.js:94
            const err = new Error('Asteroid connection timeout');
                        ^

Error: Asteroid connection timeout
    at Timeout._onTimeout (/home/jerryberry12/hopebot/node_modules/@rocket.chat/sdk/dist/lib/driver.js:94:25)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)

Node.js v19.8.1

In my server.js file, all the settings, bot info and passwords are correct. It seems like some default settings are being applied because of this:

[connect] Connecting {
  username: 'bot',
  password: 'pass',

I set these fields correctly in server.js, not bot and pass. Can some one help me?

Server info

I'm using Raspbian 10 Lite, on a raspberry pi. I installed rocketchat.sdk as shown in the tutorial.

JerryBerry12 avatar Mar 24 '23 23:03 JerryBerry12

Hi, I have the same problem. The snippet provided in the rocket.chat site is not working and it is throwing the same timeout exception on the line:

await driver.connect({ host: HOST, useSsl: SSL })

I already double checked that the HOST and SSL var are corrected setted.

felipecrp avatar Apr 11 '23 15:04 felipecrp

I managed to get it to work. 🙌

Despite my rocket chat is using https, when I used the SSL = true, I got the timeout. But, when i use SSL = false I managed to connect to the rocket.chat instance.

felipecrp avatar Apr 11 '23 15:04 felipecrp

hmm. I was already using SSL = false. you can see my config above. I'll try setting to true

JerryBerry12 avatar Apr 11 '23 20:04 JerryBerry12

Nope both ways doesn't work Lemme try botpress, since I just got support for that connecter by updating software to v6.

JerryBerry12 avatar May 06 '23 22:05 JerryBerry12

@JerryBerry12 if rocketchat sdk version is 0.2.9-2 must use node 16 else must use node >=18 fot fix a 'Asteroid connection timeout' use this

export NODE_TLS_REJECT_UNAUTHORIZED=0 - Mac
set NODE_TLS_REJECT_UNAUTHORIZED=0 - windows
export NODE_TLS_REJECT_UNAUTHORIZED=0 - linux

MrPoint1400 avatar Jun 14 '23 04:06 MrPoint1400

Nope both ways doesn't work

You should try setting it to ''

Ananya2001-an avatar Dec 24 '23 17:12 Ananya2001-an