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

Rocketchat hubot shows connected successfully but not showing green light in rocket.chat application #350

Open
janardna opened this issue Dec 11, 2023 · 1 comment

Comments

@janardna
Copy link

janardna commented Dec 11, 2023

Hi, i am new to rocket.chat and hubot, i created ec2 instance and running rocket.chat version 6.2.12 and i am running the hubot as well, in hubot configuration i create one user in rocket.chat and given that user details in hubot .
when i run the hubot docker container or script it shows successfully connected in logs when i checked in the rocket.chat application, its not showing green light
instead of login using script or docker, if go and login using web app(rocket.chat) it showing green light(dot)

any suggestions that would be helpful for me!

hubot logs

[Mon Dec 11 2023 06:44:45 GMT+0000 (Coordinated Universal Time)] INFO [startup] Rocket.Chat adapter in use
[Mon Dec 11 2023 06:44:45 GMT+0000 (Coordinated Universal Time)] INFO [startup] Respond to name: Hubot
[Mon Dec 11 2023 06:44:45 GMT+0000 (Coordinated Universal Time)] INFO [startup] Respond to alias: jana
[Mon Dec 11 2023 06:44:45 GMT+0000 (Coordinated Universal Time)] INFO [connect] Connecting {
username: 'jana',
password: '123456',
ldap: false,
host: 'janapk.io:443',
useSsl: true,
timeout: 20000,
rooms: [],
allPublic: true,
dm: true,
livechat: true,
edited: true,
integrationId: 'js.SDK',
roomCacheMaxSize: 10,
roomCacheMaxAge: 300000,
dmCacheMaxSize: 10,
dmCacheMaxAge: 100000
}
[Mon Dec 11 2023 06:44:46 GMT+0000 (Coordinated Universal Time)] INFO [connect] Connected
[Mon Dec 11 2023 06:44:46 GMT+0000 (Coordinated Universal Time)] INFO [login] Logging in jana
[Mon Dec 11 2023 06:44:46 GMT+0000 (Coordinated Universal Time)] INFO [subscribe] Preparing subscription: stream-room-messages: my_messages
[Mon Dec 11 2023 06:44:46 GMT+0000 (Coordinated Universal Time)] INFO [subscribe] Stream ready: 2
[Mon Dec 11 2023 06:44:46 GMT+0000 (Coordinated Universal Time)] INFO [reactive] Listening for change events in collection stream-room-messages

@janardna janardna changed the title Rocketchat hubot shows connected successfully but not showing green light Rocketchat hubot shows connected successfully but not showing green light in rocket.chat application Dec 11, 2023
@vonfatt
Copy link

vonfatt commented Jan 10, 2025

Hi,

it's been more than a year, but maybe someone will find it useful.
We also struggled with the issue and finally decided to open at the start of hubot a web socket which turns the 'connected' icon green. It's like this:

var ws = new WebSocket(`ws://{{ROCKETCHAT_URL}}/websocket`);

ws.onerror = e => {console.error('Cannot connect to RocketChat server. WebSocket error:',e);};
ws.onclose = (c,r) => {console.log('WebSocket closed with code',c,' and reason:',r);};

ws.onopen = () => {
  console.log('WebSocket with RocketChat server established');

  //Connect 
  ws.send(JSON.stringify({"msg": "connect","version": "1","support": ["1"]}));

  // Login 
  ws.send(JSON.stringify({
    msg: 'method',
    method: 'login',
    id: login_msg_id,
    params: [
      {
        user: { username: {{USERNAME}} },
        password: {
          digest: crypto.createHash('sha256').update( {{PASSWORD}} ).digest('hex'),
          algorithm: 'sha-256'
        }
      }
    ]
  }));
};

//Respond to ping to keep the green icon 
ws.onmessage = msg => {
  try{
    const res = JSON.parse(msg.data);
    // pong after ping
    if(res.msg=='ping') ws.send(JSON.stringify({msg:'pong'}));
    // On login confirmation
    else if(res.id==login_msg_id)
      //Send token again - otherwise RocketChat status is not updated in clients
      ws.send(JSON.stringify({
        msg: 'method',
        id: 'token',
        method: 'login',
        params: [{'resume': res.result.token}]
      }));
    }catch(e){console.error('Received message data error:',e,'msg:',msg.data);}
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants