zeromq / chumak

Pure Erlang implementation of ZeroMQ Message Transport Protocol.
Mozilla Public License 2.0
197 stars 47 forks source link

Is it possible to connect a dealer - dealer? #29

Closed osmuogar closed 6 years ago

osmuogar commented 6 years ago

I'm trying to make a simple application which has a erlang client and a node server. Both need to be dealers connected and I cant get them to work.

Client

  application:start(chumak),
  {ok, Socket } = chumak:socket(dealer),
  Res = chumak:connect(Socket, tcp, "127.0.0.1", 9000),
  io:format("Connected Socket ~p~n",[Res]),
  Message = [<<"Hello">>, <<"world">>],
  chumak:send_multipart(Socket, Message),
  io:format("Sended multipart message ~p~n",[Message]).

Server

var zmq = require('zeromq');
var socket = zmq.socket('dealer');

socket.on('message', (message) => {
  console.log('received: %s', JSON.stringify(message));
  console.log('message to string ' + message.toString("utf8"));
});

socket.bind('tcp://127.0.0.1:9000', (error) => {
  if (error) {
    console.error("Error binding the socket to the port: " + error);
  }
  console.log('Socket listening on port 9000');
});

If the type of the server socket changes, then something is received, else no message is received.

This is part of a bigger project and the socket types on the server can't be changed.. Am I doing something wrong?

drozzy commented 6 years ago

I don't remember how dealer is supposed to work anymore (maybe someone else can chime in?)

But make sure you are sending the correct multipart message: http://zguide.zeromq.org/php:chapter3#toc19

If you figure it out, it would be nice to have the official guide example in erlang using Chumak as well.