zeromq / netmq

A 100% native C# implementation of ZeroMQ for .NET
Other
2.95k stars 744 forks source link

NetMQ resolves a hostname to IP for Options.LastEndpoint, but cannot reconnect to IP because original connection was to hostname #932

Open fowie opened 4 years ago

fowie commented 4 years ago

socket.Options.LastEndpoint does not always contain the actual last endpoint of a socket. LastEndpoint appears to contain the resolved uri of an endpoint, even if a hostname was originally used in the socket.connect call. This makes it so that socket.disconnect(socket.Options.LastEndpoint) does not work with hostnames, because the internal zeroMQ socket was not connected with the resolved URI, but with the hostname URI.

Environment

NetMQ Version:    4.0.0.207
Operating System:  Windows 10
.NET Version:     net472

Expected behaviour

socket.Options.LastEndpoint should contain the actual Uri used in the Connect string socket.Disconnect should not fail to disconnect from socket.Options.LastEndpoint

Actual behaviour

socket.Options.LastEndpoint contains the resolved IP address from c:\windows\system32\drivers\etc\hosts, and attempts to call socket.Disconnect(socket.Options.LastEndpoint) cause a NetMQ EndpointNotFoundException

Steps to reproduce the behaviour

Create a socket using the form socket.Connect("tcp://HOSTNAME:PORT"); where HOSTNAME is a hostname, not an IP address. In my case HOSTNAME is defined in c:\windows\system32\drivers\etc\hosts: 192.168.1.66 nano-000 Once created, socket.Options.LastEndpoint will show: "tcp://192.168.1.66:PORT", not the hostname. Attempt to disconnect from the endpoint using: socket.Disconnect(socket.Options.LastEndpoint)

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had activity for 365 days. It will be closed if no further activity occurs within 56 days. Thank you for your contributions.