场景:
我正在尝试String
通过 ZeroMQ 从 C# сonsole 应用程序向 Node.JS 服务器发送数据(比如类型)。
信息:
分别将 clrzmq 用于 c# 和 ZeroMQ 库用于 C# 和 Node.JS
因此,确认一件事是ZeroMQ - 智能传输层已安装在机器上(Windows 7 64 位)
问题:
我无法将数据从 C# 控制台应用程序推送到 Node.JS 应用程序(甚至尝试反之亦然),两者都在同一台机器上和同一地址上,即tcp://127.0.0.1:2222
Node.js 代码:
var zmq = require('zeromq.node');
var pull_socket = zmq.socket('pull');
pull_socket.connect('tcp://127.0.0.1:2222');
pull_socket.on('message', function (data) {
console.log('received data:\n');
console.log(data);
});
C#代码:
namespace DataServiceEngine
{
class Program
{
static void Main(string[] args)
{
//clsApp App = new clsApp();
//App.appId = "001";
//App.name = "Back Office";
//Console.WriteLine("appId :" + App.appId + "\n");
//Console.WriteLine("name:" + App.name + "\n");
try
{
// ZMQ Context and client socket
using (var context = new Context(1))
{
using (Socket client = context.Socket(SocketType.PUSH))
{
client.Connect("tcp://127.0.0.1:2222");
string request = "Hello";
for (int requestNum = 0; requestNum < 10; requestNum++)
{
Console.WriteLine("Sending request {0}...", requestNum);
client.Send(request, Encoding.Unicode);
string reply = client.Recv(Encoding.Unicode);
Console.WriteLine("Received reply {0}: {1}", requestNum, reply);
}
}
}
}
catch (ZMQ.Exception exp)
{
Console.WriteLine(exp.Message);
}
}
}
}
问题:谁能告诉我可能是什么原因或我在哪里做错了?