RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.61k stars 10.61k forks source link

RocketChat service listening on two ports (3000 and a random one) #30541

Open athoik opened 1 year ago

athoik commented 1 year ago

Description:

Hi,

I am having the latest version of rocketchat 6.4, and after inspecting the system ports, I noticed that rocketchat is listening on two ports.

The service already has PORT=3000 and BIND_IP=127.0.0.1 but that doesn't seem to affect the second port.

root@rocket-chat:~# ps aux | grep Rocket.Chat | grep node
rocketc+     741  0.8 29.7 1862520 580356 ?      Ssl  15:21   0:35 /usr/local/bin/node /opt/Rocket.Chat/main.js
root@rocket-chat:~# ss -tunpl | egrep "node|Netid"
Netid State  Recv-Q Send-Q Local Address:Port  Peer Address:PortProcess
tcp   LISTEN 0      511        127.0.0.1:3000       0.0.0.0:*    users:(("node",pid=741,fd=40))
tcp   LISTEN 0      511                *:41305            *:*    users:(("node",pid=741,fd=31))

root@rocket-chat:~# systemctl restart rocketchat.service

root@rocket-chat:~# ps aux | grep Rocket.Chat | grep node
rocketc+    1059 86.7 30.6 1598728 596256 ?      Dsl  16:33   0:13 /usr/local/bin/node /opt/Rocket.Chat/main.js
root@rocket-chat:~# ss -tunpl | egrep "node|Netid"
Netid State  Recv-Q Send-Q Local Address:Port  Peer Address:PortProcess
tcp   LISTEN 0      511        127.0.0.1:3000       0.0.0.0:*    users:(("node",pid=1059,fd=41))
tcp   LISTEN 0      511                *:45311            *:*    users:(("node",pid=1059,fd=34))

As you can notice above as expected, the RocketChat honors BIND_IP and PORT, but the second random port, ignores them.

Connecting to that port (eg via telnet or using curl http://localhost:random-port) show the following error in logs:

root@rocket-chat:~# journalctl -f
Oct 01 16:34:04 rocket-chat rocketchat[1059]: |      MongoDB Version: 5.0.21                                |
Oct 01 16:34:04 rocket-chat rocketchat[1059]: |       MongoDB Engine: wiredTiger                            |
Oct 01 16:34:04 rocket-chat rocketchat[1059]: |             Platform: linux                                 |
Oct 01 16:34:04 rocket-chat rocketchat[1059]: |         Process Port: 3000                                  |
Oct 01 16:34:04 rocket-chat rocketchat[1059]: |             Site URL: https://rocket-chat.local             |
Oct 01 16:34:04 rocket-chat rocketchat[1059]: |     ReplicaSet OpLog: Enabled                               |
Oct 01 16:34:04 rocket-chat rocketchat[1059]: |          Commit Hash: e2f60199ab                            |
Oct 01 16:34:04 rocket-chat rocketchat[1059]: |        Commit Branch: HEAD                                  |
Oct 01 16:34:04 rocket-chat rocketchat[1059]: |                                                             |
Oct 01 16:34:04 rocket-chat rocketchat[1059]: +-------------------------------------------------------------+
Oct 01 16:38:25 rocket-chat rocketchat[1059]: [2023-10-01T13:38:25.693Z] WARN  bef7d331-fbe3-4631-934a-ca9af49585a5/TRANSPORTER: Packet parser error! Error: Invalid packet CRC! 62
Oct 01 16:38:25 rocket-chat rocketchat[1059]:     at Parser._write (/opt/Rocket.Chat/programs/server/npm/node_modules/moleculer/src/transporters/tcp/parser.js:56:15)
Oct 01 16:38:25 rocket-chat rocketchat[1059]:     at writeOrBuffer (internal/streams/writable.js:358:12)
Oct 01 16:38:25 rocket-chat rocketchat[1059]:     at Parser.Writable.write (internal/streams/writable.js:303:10)
Oct 01 16:38:25 rocket-chat rocketchat[1059]:     at Socket.ondata (internal/streams/readable.js:731:22)
Oct 01 16:38:25 rocket-chat rocketchat[1059]:     at Socket.emit (events.js:400:28)
Oct 01 16:38:25 rocket-chat rocketchat[1059]:     at Socket.emit (domain.js:475:12)
Oct 01 16:38:25 rocket-chat rocketchat[1059]:     at addChunk (internal/streams/readable.js:293:12)
Oct 01 16:38:25 rocket-chat rocketchat[1059]:     at readableAddChunk (internal/streams/readable.js:267:9)
Oct 01 16:38:25 rocket-chat rocketchat[1059]:     at Socket.Readable.push (internal/streams/readable.js:206:10)
Oct 01 16:38:25 rocket-chat rocketchat[1059]:     at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
Oct 01 16:38:25 rocket-chat rocketchat[1059]:     at TCP.callbackTrampoline (internal/async_hooks.js:130:17)

From above log I guess is related with moleculer.

Searching on RocketChat didn't notice any instructions how to disable that port or make it listening on loopback only etc.

This blog mentions that you are already working with moleculer but no further instructions.

How can we change that port to listen only on loopback? Or how we can disable it?

Thanks a lot.

Server Setup Information:

v-a14 commented 1 year ago

I want to work on this issue,please assign me to this ?

houjuan0623 commented 1 year ago

As you mentioned above,"Manual Installation" means do you download the production version of the package or package it yourself?

I konw meteor will start a proxy port. 3000 is the proxy port, random port is the listening port that provides the real service.

athoik commented 1 year ago

By manual installation I mean the procedure documented here: https://docs.rocket.chat/deploy/deploy-rocket.chat/additional-deployment-methods/deploy-on-debian

Process id that runs RocketChat, starts a random port (33085 as seen below), listening on all interfaces.

root@rocket-chat:~# ss -tunpl | egrep "node|Netid"
Netid State  Recv-Q Send-Q Local Address:Port  Peer Address:PortProcess                                                          
tcp   LISTEN 0      511        127.0.0.1:3000       0.0.0.0:*    users:(("node",pid=5490,fd=40))                                 
tcp   LISTEN 0      511                *:33085            *:*    users:(("node",pid=5490,fd=31))                            

Connecting to that port shows the moleculer error bellow.

Oct 28 22:29:13 rocket-chat rocketchat[5490]: +-------------------------------------------------------------+
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |                        SERVER RUNNING                       |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: +-------------------------------------------------------------+
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |                                                             |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |  Rocket.Chat Version: 6.4.4                                 |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |       NodeJS Version: 14.21.3 - x64                         |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |      MongoDB Version: 5.0.21                                |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |       MongoDB Engine: wiredTiger                            |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |             Platform: linux                                 |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |         Process Port: 3000                                  |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |             Site URL: https://rocket-chat.local             |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |     ReplicaSet OpLog: Enabled                               |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |          Commit Hash: d994a6ff33                            |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |        Commit Branch: HEAD                                  |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: |                                                             |
Oct 28 22:29:13 rocket-chat rocketchat[5490]: +-------------------------------------------------------------+
Oct 28 22:31:39 rocket-chat rocketchat[5490]: [2023-10-28T19:31:39.905Z] WARN  a6597d77-58bb-4d83-afa8-1428a0db5317/TRANSPORTER: Packet parser error! Error: Invalid packet CRC! 57
Oct 28 22:31:39 rocket-chat rocketchat[5490]:     at Parser._write (/opt/Rocket.Chat/programs/server/npm/node_modules/moleculer/src/transporters/tcp/parser.js:56:15)
Oct 28 22:31:39 rocket-chat rocketchat[5490]:     at writeOrBuffer (internal/streams/writable.js:358:12)
Oct 28 22:31:39 rocket-chat rocketchat[5490]:     at Parser.Writable.write (internal/streams/writable.js:303:10)
Oct 28 22:31:39 rocket-chat rocketchat[5490]:     at Socket.ondata (internal/streams/readable.js:731:22)
Oct 28 22:31:39 rocket-chat rocketchat[5490]:     at Socket.emit (events.js:400:28)
Oct 28 22:31:39 rocket-chat rocketchat[5490]:     at Socket.emit (domain.js:475:12)
Oct 28 22:31:39 rocket-chat rocketchat[5490]:     at addChunk (internal/streams/readable.js:293:12)
Oct 28 22:31:39 rocket-chat rocketchat[5490]:     at readableAddChunk (internal/streams/readable.js:267:9)
Oct 28 22:31:39 rocket-chat rocketchat[5490]:     at Socket.Readable.push (internal/streams/readable.js:206:10)
Oct 28 22:31:39 rocket-chat rocketchat[5490]:     at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
Oct 28 22:31:39 rocket-chat rocketchat[5490]:     at TCP.callbackTrampoline (internal/async_hooks.js:130:17)
rmaksimov commented 1 year ago

The same problem with Rocket.Chat Version: 6.4.5