The project has a web background. The operations in the background issue instructions for the settings of the hardware devices. However, the hardware devices use the TCP protocol, so a separate TCP service is set up to communicate with the hardware, and two processes are run separately. What happens when the user operates in the background? Information, what is the best way to communicate with the tcp service?
Nodejs can start a tcp link. Start the tcp connection service before starting the web. The tcp service needs to maintain the tcp connection status (such as disconnection and reconnection, etc.), and then directly call the tcp connection service in the web service for communication. , which has a high degree of coupling but is more convenient to use.
Is it nodejs?
It is best to use the same process, so that you do not have to consider inter-process communication issues.
If you have to run in two processes, then use a third party, such as redis pub/sub. Both processes serve as clients to connect to a redis service, one publish and one subscribe.
When the project web backend receives a browser request, it directly starts sending TCP data communication to the device. After getting the result, it directly parses and returns it to the browser.
Why do you need to open another TCP service process?
Should I think carefully about how to describe the problem clearly before asking the question?
My mobile phone address may have been used by someone