Cannot receive messages on ZeroMQ susbcriber VM (VirtualBox)

I have two OpenWrt (18.06.4) VM's (A and B) in VirtualBox and I'm trying to send messages in a publisher-subscriber scheme using ZeroMQ. A is the server, B is the client.

I'm using the following code:

and it works on my computer, so I decided to try it on the VMs.

I had to compile both (using the SDK) so I can execute them in the VMs. I compiled two times, changing one minor detail:

1) client listening to the IP 10.0.1.4 of the server

2) client listening to the IP 192.168.56.10 of the server

Both versions were tested in the VMs and in both, the server sends the messages (the send function executes and prints the message sent) but the client never receives any message (message is always null).

About my network configuration. In VirtualBox, I have a Nat Network (10.0.1.0/24) and a virtualbox network (192.168.56.1/24). Both VM A and B have a host-only adapter (vboxnet0) and a NAT network adapter. The machines can ping each other.

The network configuration of the machines is the following:

A

config interface 'loopback'
    option ifname 'lo'
    option proto 'static'
    option ipaddr '127.0.0.1'
    option netmask '255.0.0.0'

config globals 'globals'
    option ula_prefix 'fd03:84ea:bc33::/48'

config interface 'lan'
    option ifname 'eth0'
        option proto 'static'
    option ipaddr '192.168.56.10'
    option netmask '255.255.255.0'

config interface 'wan'
    option ifname 'eth1'
    option proto 'dhcp'

Note: The NAT network IP ('wan') is currently 10.0.1.4

B

config interface 'loopback'
    option ifname 'lo'
    option proto 'static'
    option ipaddr '127.0.0.1'
    option netmask '255.0.0.0'

config globals 'globals'
    option ula_prefix 'fdea:4700:64aa::/48'

config interface 'lan'
    option ifname 'eth0'
    option proto 'static'
    option ipaddr '192.168.56.20'
    option netmask '255.255.255.0'

config interface 'wan'
    option ifname 'eth1'
    option proto 'dhcp'

Note: The NAT network IP ('wan') is currently 10.0.1.5

Do you guys have any idea what the problem might be? Should I change the network configuration inside each VM and/or change the adapters on VirtualBox?

paste your C code... the C code you linked will obviously not work;

    zmq_connect (subscriber, "tcp://localhost:5563");
    zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, "B", 1);

The code is exactly the same, I just changed the IP:

Subscriber:

#include "zhelpers.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main (void)
{
    //  Prepare our context and subscriber
    void *context = zmq_ctx_new ();
    void *subscriber = zmq_socket (context, ZMQ_SUB);
    zmq_connect (subscriber, "tcp://10.0.1.4:5563");
    zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, "B", 1);

    while (1) {
        //  Read envelope with address
        char *address = s_recv (subscriber);
        //  Read message contents
        char *contents = s_recv (subscriber);
	if(contents){
        	printf ("[%s] %s\n", address, contents);
        }
	else{
		printf("No message received\n");
		sleep(1);
	}
	free (address);
        free (contents);
    }
    //  We never get here, but clean up anyhow
    zmq_close (subscriber);
    zmq_ctx_destroy (context);
    return 0;
}

Publisher:

//  Pubsub envelope publisher
//  Note that the zhelpers.h file also provides s_sendmore

#include "zhelpers.h"
#include <unistd.h>

int main (void)
{
    //  Prepare our context and publisher
    void *context = zmq_ctx_new ();
    void *publisher = zmq_socket (context, ZMQ_PUB);
    zmq_bind (publisher, "tcp://*:5563");

    while (1) {
        //  Write two messages, each with an envelope and content
        s_sendmore (publisher, "A");
        s_send (publisher, "We don't want to see this");
        s_sendmore (publisher, "B");
        s_send (publisher, "We would like to see this");
        printf("We would like to see this\n");
        sleep (1);
    }
    //  We never get here, but clean up anyhow
    zmq_close (publisher);
    zmq_ctx_destroy (context);
    return 0;
}

well if you can ping....

lsof or strace and firewall stop will tell you the rest...