[zeromq-dev] Perl bindings ZeroMQ block publishing messages to Mojolicous over WebSocket

Manu Agarwal magarwal at rblt.com
Fri Jan 4 21:26:44 CET 2013


Hi,

I am trying to write a simple Perl code which subscribe messages from ZeroMQ and publish them over WebSocket using Mojolicious.
As soon as I subscribe to zeromq for receiving messages, the websocket sent part stops working.
If I try to dump the $self->tx, I see the messages and the correct client information, but no data is being sent.

Please find below a sample code snippet for this,

#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;
use Mojolicious::Lite;
use ZMQ::LibZMQ3;
use ZMQ::Constants qw(:all);

websocket '/paper' => sub {
                my $self = shift;

                my $ctxt = zmq_init;
                my $socket = zmq_socket( $ctxt, ZMQ_SUB );
                zmq_connect( $socket, "tcp://manu.rsi.com:7000" );

                $self->app->log->debug('WebSocket connected.');

                $self->send('WebSocket connected.');

                zmq_setsockopt($socket,ZMQ_SUBSCRIBE,ZMQ_NOBLOCK);
                while(my $msg = zmq_recvmsg( $socket )){
                                $self->send("Received a message data");
                }

                zmq_close($socket);

};

app->start;


Please let me know if I am missing something or is there a different way to achieve this.
I am trying a simple glue code, which gets Messages over ZeroMQ and send over Mojo WebSocket.

Thanks
Manu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130104/51d97d4c/attachment.htm>


More information about the zeromq-dev mailing list