Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to know if connection was successful and is alive? #954

Open
maxima120 opened this issue Dec 6, 2020 · 3 comments
Open

How to know if connection was successful and is alive? #954

maxima120 opened this issue Dec 6, 2020 · 3 comments

Comments

@maxima120
Copy link

How do I know if connection is well and alive?

I connected to an non-existing IP by mistake and found that nothing happened in my code as if it was connected OK.. Only no messages came through :)

Environment

NetMQ 4.0.1.6:    
Operating System: Windows 10 x64
.NET Version:   .NET 5.0

Actual behaviour

SubscriberSocket .Connect(server) throws no errors if server doesnt exist

Expected behaviour

  • SubscriberSocket .Connect(server) should throw an error if server doesnt exist

  • an event handler/action has to be called called if disconnect or connection broken at any time

  • there has to be a method to check if connection is alive at any time

@b2yq
Copy link

b2yq commented Feb 15, 2021

You can always implement a simple "heart-beat" pattern to check if endpoint alive. This pattern is fully described in Zero-Mq docs

@stale
Copy link

stale bot commented Apr 17, 2022

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.

@stale stale bot added the stale label Apr 17, 2022
@jramram
Copy link

jramram commented Jun 21, 2022

Hi,

For detecting when a socket disconnects I use NetMQMonitor

subscriberSocket = new SubscriberSocket();
subscriberSocket.Connect(addr);

netMQPoller = new NetMQPoller
          {
              subscriberSocket
          };

netMQPoller.RunAsync();
NetMQMonitor monitor = new NetMQMonitor(subscriberSocket, $"inproc://addr:1234", SocketEvents.All);
monitor.Connected += _monitor_Connected;
monitor.Disconnected += _monitor_Disconected;

@stale stale bot removed the stale label Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants