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

Daisuke Maki lestrrat at gmail.com
Sat Jan 5 12:54:10 CET 2013


> Please let me know if I am missing something or is there a different way
to achieve this.****
This is wrong:

>                zmq_setsockopt($socket,ZMQ_SUBSCRIBE,ZMQ_NOBLOCK);

**
This needs to be two calls:

    zmq_setsocktop($socket, ZMQ_SUBSRCRIBE, $SUBSCRIBE_STRING);
    zmq_recvmsg($socket, ZMQ_DONTWAIT); # DONTWAIT == new name for NOBLOCK

When in doubt, ALWAYS READ THE DOCS FOR THE C API.
`man zmq_setsockopt` would quickly show that DONTWAIT/NOBLOCK doesn't
belong there.
`man zmq_recvmsg` shows that DONTWAIT should be specified in the flags

--d

2013/1/5 Manu Agarwal <magarwal at rblt.com>

>  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****
>
> ** **
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>


2013/1/5 Manu Agarwal <magarwal at rblt.com>

>  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****
>
> ** **
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130105/abf21a91/attachment.htm>


More information about the zeromq-dev mailing list