node.js - How to best communicate with each other between http service and tcp service?
PHP中文网
PHP中文网 2017-05-16 13:38:05
0
4
809

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?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(4)
滿天的星座

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template