Error in zeromq self-connection

Source: Internet
Author: User
Error in zeromq self-connection

(Jinqing's column)

The server and client developed by zeromq message middleware do not need to be started in order. The client can be started before the server is enabled. This is a particularly useful feature of zmq. With this feature, the online game function servers can be restarted at will to enable automatic restart and continuous server upgrades.

In the traditional network connection mode, the processes that serve as internal servers in the online game server group must be restarted at the same time, otherwise the TCP connections between them will be disconnected. For example, the database proxy process is a service process, and all other processes are its client processes. Therefore, when the database proxy restarts, other processes also need to be restarted. The database proxy process must be started earlier than other processes. Without such order restrictions, the database proxy process can be restarted at will, and the service can be upgraded at any time without stopping services.

However, an error is also found. When a client process and a server process are on the same machine, if the service is not enabled, start the client process first. After a long period of time, you will find that the client process has established a connection with itself. The netstat display is as follows:

TCP 127.0.0.1: 34567 127.0.0.1: 34567 established

The local port number is the same as the remote port number, that is, the Service port. And then start the server process will fail because the port is occupied. The client will receive the data sent by itself.

This is because the client continuously uses random local ports to connect to the Service port, the connection fails, and the local port keeps changing until the local port is equal to the Service port. The above self-connection will be generated.

We have submitted a suggestion to disconnect the self-connection:
Https://zeromq.jira.com/browse/LIBZMQ-549

When the connection finds that the local port is equal to the Service port, it will be disconnected and the local port will be reconnected, so there will be no self-connection.

If the service process is on different machines, there will be no self-connection. Or the server can start up early. In addition, the random connection takes a long time, and the service is generally started before that.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.