Scenario:
我正在尝试发送数据(例如String
类型)通过 ZeroMQ 从 C# 控制台应用程序到 Node.JS 服务器。
信息:
分别对 C# 使用 clrzmq,对 C# 和 Node.JS 使用 ZeroMQ 库
我有能力执行推拉 https://github.com/JustinTulloss/zeromq.node/blob/master/examples/push_pull.js也来自 Node.JSpush https://github.com/zeromq/clrzmq#example-client - pull https://github.com/zeromq/clrzmq#example-server来自 C#。
那么,有一件事可以确定,那就是ZeroMQ - 智能传输层 http://www.zeromq.org/已安装在计算机上(Windows 7 64 位)
Issue:
我无法将数据从 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# code:
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);
}
}
}
}
Question: 谁能告诉我可能是什么原因或者我哪里做错了?