I'm working with two independent nodejs processes, the first one is an server over TCP, and the second is an express app that listen for HTTP requests. My problem is how can i handle the communication between those two processes?
Asked
Active
Viewed 544 times
0
-
How much communication will be going on? What type? How much control do you have over the source code for each program? Do you _need_ two separate processes? – The Guy with The Hat Sep 18 '18 at 17:56
-
Yes they are separate processes and i want to exchange data between them. – Hakraf Sep 20 '18 at 14:36
1 Answers
2
Plenty of options:
launch one process from another using child_process and communicate using stdin/stdout
have your express app also open a TCP connection to your TCP server (on a different port than the one already in use), and communicate via tcp/ip
- communicate via HTTP, by implementing another API on your express server
- use node-ipc, an inter-process communication module
- use a message queue library like zeromq
- communicate via a database: each process reads and writes to the same database
- communicate using a plain text file: each process reads and writes to the file
I think the list could go on.

mihai
- 37,072
- 9
- 60
- 86