Closed MrSzymonello closed 1 year ago
Here is the fix. The Form1.cs should like that
using System;
using System.Windows.Forms;
using NetMQ;
using NetMQ.Sockets;
namespace PublisherWindowsFormsApp
{
public partial class Form1 : Form
{
private readonly PublisherSocket publisher = new PublisherSocket();
public Form1()
{
publisher.Bind("tcp://127.0.0.1:8888");
InitializeComponent();
}
private void buttonPublish_Click(object sender, EventArgs e)
{
publisher
.SendMoreFrame("COMMAND")
.SendFrame(textBoxCommand.Text);
}
}
}
not like that
using System;
using System.Windows.Forms;
using NetMQ;
using NetMQ.Sockets;
namespace PublisherWindowsFormsApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void buttonPublish_Click(object sender, EventArgs e)
{
using (var publisher = new PublisherSocket())
{
publisher.Bind("tcp://127.0.0.1:8888");
publisher
.SendMoreFrame("COMMAND")
.SendFrame(textBoxCommand.Text);
}
}
}
}
Environment
Expected behaviour
The Pub/Sub model works when Publisher is a Windows Forms application.
Actual behaviour
Messages published from Windows Forms application do not reach the Subscriber.
Steps to reproduce the behaviour
Clone repository https://github.com/MrSzymonello/NetMqPubSubConsoleVsWinForms The repository contains 3 projects: Subscriber, Console Application Publisher and Windows Forms Publisher. Run Subscriber and Console Publisher. It works. Run Subscriber and Windows Forms Publisher. It does not work. Messages do not reach the Subscriber.