RocketChat / RocketChat/Rocket.Chat
RocketChat service listening on two ports (3000 and a random one)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
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:
- Version of Rocket.Chat Server: 6.4
- Operating System: Debian 12
- Deployment Method: Manual Installation
- Number of Running Instances: 1
- DB Replicaset Oplog: wiredTiger (oplog Enabled)
- NodeJS Version: 14.21.3
- MongoDB Version: 5.0.21
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the service entry point at /opt/Rocket.Chat/main.js and the Moleculer transporter path shown in programs/server/npm/node_modules/moleculer/src/transporters/tcp/parser.js. Reproduce the two listeners with ss and identify where the random transporter port and bind address are configured. Done means the behavior is explained and the port can be disabled or restricted to loopback, with the result verified after restart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100