nanomsg library

Related tags

nanomsg
Overview

Welcome to nanomsg

Release MIT License Linux Status Windows Status Coverage Gitter

The nanomsg library is a simple high-performance implementation of several "scalability protocols". These scalability protocols are light-weight messaging protocols which can be used to solve a number of very common messaging patterns, such as request/reply, publish/subscribe, surveyor/respondent, and so forth. These protocols can run over a variety of transports such as TCP, UNIX sockets, and even WebSocket.

For more information check the website.

Prerequisites

  1. Windows.

    • Windows Vista or newer (Windows XP and 2003 are NOT supported)
    • Microsoft Visual Studio 2010 (including C++) or newer, or mingw-w64. (Specifically mingw and older Microsoft compilers are *NOT supported, and we do not test mingw-w64 at all, so YMMV.)
    • CMake 2.8.7 or newer, available in $PATH as cmake
  2. POSIX (Linux, MacOS X, UNIX)

    • ANSI C compiler supporting C89
    • POSIX pthreads (should be present on all modern POSIX systems)
    • BSD sockets support for both TCP and UNIX domain sockets
    • CMake (http://cmake.org) 2.8.7 or newer, available in $PATH as cmake
  3. Documentation (optional)

Quick Build Instructions

These steps here are the minimum steps to get a default Debug build. Using CMake you can do many other things, including setting additional variables, setting up for static builds, or generation project or solution files for different development environments. Please check the CMake website for all the various options that CMake supports.

POSIX

This assumes you have a shell in the project directory, and have the cmake and suitable compilers (and any required supporting tools like linkers or archivers) on your path.

  1. % mkdir build
  2. % cd build
  3. % cmake ..
  4. % cmake --build .
  5. % ctest .
  6. % sudo cmake --build . --target install
  7. % sudo ldconfig (if on Linux)

Windows

This assumes you are in a command or powershell window and have the appropriate variables setup to support Visual Studio, typically by running vcvarsall.bat or similar with the appropriate argument(s). It also assumes you are in the project directory.

  1. md build
  2. cd build
  3. cmake ..
  4. cmake --build . --config Debug
  5. ctest -C Debug .
  6. cmake --build . --config Debug --target install NB: This may have to be done using an Administrator account.

Alternatively, you can build and install nanomsg using vcpkg dependency manager:

  1. git clone https://github.com/Microsoft/vcpkg.git
  2. cd vcpkg
  3. ./bootstrap-vcpkg.bat
  4. ./vcpkg integrate install
  5. ./vcpkg install nanomsg

The nanomsg port in vcpkg is kept up to date by microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

Static Library

We normally build a dynamic library (.so or .DLL) by default.

If you want a static library (.a or .LIB), configure by passing -DNN_STATIC_LIB=ON to the first cmake command.

POSIX

POSIX systems will need to link with the libraries normally used when building network applications. For some systems this might mean -lnsl or -lsocket.

Windows

You will also need to define NN_STATIC_LIB in your compilation environment when building programs that use this library. This is required because of the way Windows changes symbol names depending on whether the symbols should be exported in a DLL or not.

When using the .LIB on Windows, you will also need to link with the ws2_32, mswsock, and advapi32 libraries, as nanomsg depends on them.

Support

This library is considered to be in "sustaining" mode, which means that new feature development has ended, and bug fixes are made only when strictly necessary for severe issues.

New development is now occurring in the NNG project, which offers both protocol and API compatibility with this project. Please consider using NNG for new projects.

Please see the file SUPPORT for more details.

Resources

Website: http://nanomsg.org

Source code: https://github.com/nanomsg/nanomsg

Documentation: http://nanomsg.org/documentation.html

Bug tracker: https://github.com/nanomsg/nanomsg/issues

Mailing list: [email protected]

Gitter Chat: https://gitter.im/nanomsg/nanomsg

IRC chatroom: #nanomsg at irc.freenode.net/8001

Issues
  • Why use CMake for Windows only ?

    Why use CMake for Windows only ?

    Why not use CMake for all builds ? Including UNIXes ?

    opened by rcari 53
  • Change from malloc to calloc

    Change from malloc to calloc

    changes to make sure that the alloced memory block is zero filled, takes a little more time but ALWAYS worth it.. to keep garbage out of the memory block.

    These changes are submitted under the MIT License

    opened by marchon 50
  • Memory leak on nn_send from REQ endpoint

    Memory leak on nn_send from REQ endpoint

    nn_device is seen to fail, where the client will receive 4 bytes too many (probably the request ID) from the server when used over a device.

    Please read down til near the end, to get the full details; the history of messages that led us to this conclusion is -- convoluted.

    Original description (which ultimately led to this bug, below):

    Using req/rep model, on NN_REQ enpoint I send messages with nn_send(..., NN_DONTWAIT) and wait for NN_POLLIN event of nn_poll with dynamic timeout. If nothing recieved, another message can be send after some time (during which the response to the previous can come). If the response really comes, then we have a memory leak. At least, it looks like this. The workaround is call of nn_recv(..., NN_DONTWAIT) just before any nn_send; but it seems strange.

    opened by romanoved 43
  • Autotools

    Autotools

    Initial autotools build system and a small patch to fix some warnings triggered by the default CFLAGS

    opened by lu-zero 41
  • Providing test to demonstrate hang in nn_close on websocket transport

    Providing test to demonstrate hang in nn_close on websocket transport

    This test demonstrates an occasional hang (at least on Windows) on line 100 when the PUB socket is closed. Creating PR in order to kick off automated builds on other platforms to see if they fail here as well, or if it is limited to just Windows.

    This only appears to hang on the WebSocket transport. This could be just a problem with the WebSocket transport implementation (the most likely scenario), or it could be because the WebSocket transport incidentally requires more time to connect and perhaps disconnect sockets, as compared to say TCP, and is thus more likely to trigger a race condition.

    opened by JackDunaway 41
  • Nanomsg an order of magnitude slower than zmq

    Nanomsg an order of magnitude slower than zmq

    I thought nanomsg is supposed to be faster than zmq, but when I tested on my Thinkpad W520 running Centos6.4, I was very surprised to find out that it was an order of magnitude slower.

    Here is my program:

    #include "../src/nn.h"
    #include "../src/pair.h"
    #include <cstdio>
    #include <unistd.h>
    #include <cstring>
    #include <cassert>
    #include <pthread.h>
    #include <sys/time.h>
    
    void* Send(void* context)
    {
        int responder = nn_socket(AF_SP, NN_PAIR);
        assert(responder != -1);
        int rc = nn_connect(responder, "inproc://test");
        assert(rc >= 0);
    
        char buf[1024];
        unsigned long bytes = 0;
        int sz[] = { 16,32,64,96,128,160,192,224,256,384,512,768,1024};
        int p =0;
        for (unsigned count = 1048576; count--;)
        {
        unsigned len = sz[p];
            nn_send(responder, buf, len, 0);
        bytes += len;
        p = (p+1) % (sizeof(sz)/sizeof(sz[0]));
        }
        nn_send(responder, buf, 0, 0);
        printf("sent %lu bytes\n", bytes);
        nn_close(responder);
        return NULL;
    }
    
    
    void* Receive(void* arg)
    {
        int receiver = (long)arg;
        char buf[1024];
        unsigned long bytes = 0;
        while (1)
        {
            int len = nn_recv(receiver, buf, sizeof(buf), 0);
        if (!len)
            break;
        if (len < 0)
        {
            perror("zmq_recv");
            break;
        }
        bytes += len;
        }
        printf("received %lu bytes\n", bytes);
        return NULL;
    }
    
    int main ()
    {
        int receiver = nn_socket(AF_SP, NN_PAIR);
        assert(receiver != -1);
        int rc = nn_bind(receiver, "inproc://test");
        assert(rc >= 0);
    
        struct timeval tv;
        gettimeofday(&tv, NULL);
        unsigned long t0 = tv.tv_usec + tv.tv_sec * 1000000;
    
        pthread_t th;
        pthread_create(&th, NULL, Receive, (void*)receiver);
        Send(NULL);
        void* ret;
        pthread_join(th, &ret);
    
        gettimeofday(&tv, NULL);
        unsigned long t = tv.tv_usec + tv.tv_sec * 1000000 - t0;
        printf("elapsed=%.3f\n", t/1000000.);
        return 0;
    }
    

    On my Thinkpad W520, it takes about 3.6-4.3s to run; whereas a similar version using zmq only took 0.4s. Can someone please point out what I did wrong? Thanks!

    opened by wuz73 37
  • Mac OS X: assertion failed (aio_posix.inc)

    Mac OS X: assertion failed (aio_posix.inc)

    I have written a small echo client/server example in LuaJIT. It runs fine on Linux but on OS X I sometimes have the following error on the client side:

    Assertion failed: errno == ECONNRESET || errno == ETIMEDOUT || errno == EPIPE (/[...]/nanomsg/src/utils/aio_posix.inc:779)
    Abort trap: 6
    

    The error occurs on that line (nn_recv).

    opened by catwell 36
  • assertion failure (NN_QUEUE_NOTINQUEUE)

    assertion failure (NN_QUEUE_NOTINQUEUE)

    Assertion failed: self->next == NN_QUEUE_NOTINQUEUE (/home/mike/nanomsg/src/utils/queue.c:78)

    Program received signal SIGABRT, Aborted. [Switching to Thread 0x7ffff1e37700 (LWP 2527)] 0x00007ffff707f425 in __GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) bt #0 0x00007ffff707f425 in __GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #1 0x00007ffff7082b8b in __GI_abort () at abort.c:91 #2 0x00007ffff795d379 in nn_err_abort () from /usr/local/lib/libnanomsg.so.0.0.0 #3 0x00007ffff795e3ec in nn_queue_item_term () from /usr/local/lib/libnanomsg.so.0.0.0 #4 0x00007ffff795bf9f in nn_worker_task_term () from /usr/local/lib/libnanomsg.so.0.0.0 #5 0x00007ffff7959457 in nn_usock_term () from /usr/local/lib/libnanomsg.so.0.0.0 #6 0x00007ffff796af36 in nn_aipc_term () from /usr/local/lib/libnanomsg.so.0.0.0 #7 0x00007ffff796bceb in nn_bipc_handler () from /usr/local/lib/libnanomsg.so.0.0.0 #8 0x00007ffff795789e in nn_fsm_event_process () from /usr/local/lib/libnanomsg.so.0.0.0 #9 0x00007ffff795763b in nn_ctx_leave () from /usr/local/lib/libnanomsg.so.0.0.0 #10 0x00007ffff795c53f in nn_worker_routine () from /usr/local/lib/libnanomsg.so.0.0.0 #11 0x00007ffff795e8d4 in nn_thread_main_routine () from /usr/local/lib/libnanomsg.so.0.0.0 #12 0x00007ffff56efe9a in start_thread (arg=0x7ffff1e37700) at pthread_create.c:308 #13 0x00007ffff713cccd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112 #14 0x0000000000000000 in ?? ()

    (gdb)

    on another thread: Assertion failed: 0 (/home/mike/nanomsg/src/transports/utils/streamhdr.c:284)

    Program received signal SIGABRT, Aborted. [Switching to Thread 0x7ffff1e37700 (LWP 2533)] 0x00007ffff707f425 in __GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) bt #0 0x00007ffff707f425 in __GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #1 0x00007ffff7082b8b in __GI_abort () at abort.c:91 #2 0x00007ffff795d379 in nn_err_abort () from /usr/local/lib/libnanomsg.so.0.0.0 #3 0x00007ffff7968962 in nn_streamhdr_handler () from /usr/local/lib/libnanomsg.so.0.0.0 #4 0x00007ffff795789e in nn_fsm_event_process () from /usr/local/lib/libnanomsg.so.0.0.0 #5 0x00007ffff795763b in nn_ctx_leave () from /usr/local/lib/libnanomsg.so.0.0.0 #6 0x00007ffff795c53f in nn_worker_routine () from /usr/local/lib/libnanomsg.so.0.0.0 #7 0x00007ffff795e8d4 in nn_thread_main_routine () from /usr/local/lib/libnanomsg.so.0.0.0 #8 0x00007ffff56efe9a in start_thread (arg=0x7ffff1e37700) at pthread_create.c:308 #9 0x00007ffff713cccd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112 #10 0x0000000000000000 in ?? ()

    (gdb)

    another: Assertion failed: self->next == NN_QUEUE_NOTINQUEUE (/home/mike/nanomsg/src/utils/queue.c:78)

    Program received signal SIGABRT, Aborted. [Switching to Thread 0x7ffff1e37700 (LWP 2539)] 0x00007ffff707f425 in __GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) bt #0 0x00007ffff707f425 in __GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #1 0x00007ffff7082b8b in __GI_abort () at abort.c:91 #2 0x00007ffff795d379 in nn_err_abort () from /usr/local/lib/libnanomsg.so.0.0.0 #3 0x00007ffff795e3ec in nn_queue_item_term () from /usr/local/lib/libnanomsg.so.0.0.0 #4 0x00007ffff795bf9f in nn_worker_task_term () from /usr/local/lib/libnanomsg.so.0.0.0 #5 0x00007ffff7959457 in nn_usock_term () from /usr/local/lib/libnanomsg.so.0.0.0 #6 0x00007ffff796af36 in nn_aipc_term () from /usr/local/lib/libnanomsg.so.0.0.0 #7 0x00007ffff796bceb in nn_bipc_handler () from /usr/local/lib/libnanomsg.so.0.0.0 #8 0x00007ffff795789e in nn_fsm_event_process () from /usr/local/lib/libnanomsg.so.0.0.0 #9 0x00007ffff795763b in nn_ctx_leave () from /usr/local/lib/libnanomsg.so.0.0.0 #10 0x00007ffff795c53f in nn_worker_routine () from /usr/local/lib/libnanomsg.so.0.0.0 #11 0x00007ffff795e8d4 in nn_thread_main_routine () from /usr/local/lib/libnanomsg.so.0.0.0 #12 0x00007ffff56efe9a in start_thread (arg=0x7ffff1e37700) at pthread_create.c:308 #13 0x00007ffff713cccd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112 #14 0x0000000000000000 in ?? ()

    (gdb)

    code:

    int main(int argc, char *argv[]) { void *data = NULL; int r_len = 0; int timeout = 1000; unsigned char *s_data = NULL; int s_len = 0; int s; int a; int len; int _time=time(0); int i; int found_command=0; char file[1024]; char ipc[1024]; int ipc_num = 0;

    if (argc > 1) {
        ipc_num = atoi(argv[1]) + 1;
    } else ipc_num = 1;
    
    if (strstr(argv[0], "curl") || strstr(argv[0], "adreplace")) {
        sprintf(file, "/tmp/curl%d.ipc", ipc_num);
        sprintf(ipc, "ipc:///tmp/curl%d.ipc", ipc_num);
    
    } else {
        sprintf(file, "/tmp/adserver%d.ipc", ipc_num);
        sprintf(ipc, "ipc:///tmp/adserver%d.ipc", ipc_num);
    }
    
    // initialize mysql
    init();
    //mysql_reopen();
    s = nn_socket(AF_SP, NN_REP);
    nn_setsockopt(s, NN_SOL_SOCKET, NN_RCVTIMEO, &timeout, sizeof(timeout));
    nn_setsockopt(s, NN_SOL_SOCKET, NN_SNDTIMEO, &timeout, sizeof(timeout));
    a = nn_bind(s, ipc);
    chmod(file, 0777);
    
    printf("Bound to IPC: %s\n", ipc);
    
    _time = time(0);
    while (1) {
    
        s_len = 0;
        s_data = NULL;
        found_command=0;
    
        len = nn_recv(s, &data, NN_MSG, 0);
    

    // if (len) { if (data && ((unsigned)len >= (unsigned)sizeof(NanoPkt))) { // do whatever with data here... always be sure to set s_data, and s_len NanoPkt _pkthdr = (NanoPkt *)data; printf("NN recv len %d nanopkt cmd %d nanopkt len %d - %d %d %d\n", len, pkthdr->type, pkthdr->len, sizeof(Genreplace_Req), sizeof(Findrep_Req), sizeof(Final_Req)); for (i = 0; Commands[i].func != NULL; i++) { if (pkthdr->type == Commands[i].type) { (_Commands[i].func)((unsigned char *)data, len, &s_data, &s_len); found_command=1; break; } }

            printf("FOund command: %d\n", found_command);
    
            // just in case something went wrong.. we have to return something or we will force a stall
            if (s_data == NULL || !s_len) {
                //printf("sending null\n");
                nn_send(s, "NULL", 4, 0);
            } else {
                //printf("sending %d bytes of real data %p\n", s_len, s_data);
                nn_send(s, s_data, s_len, 0);
    

    // free(s_data); } // nn_freemsg(data); data = NULL; }

        if ((time(0) - _time) > 10) {
            _time = time(0);
            removerep();
        }
    

    // }

    }
    nn_close(s);
    

    }

    client: if ((reqptr = (Genreplace_Req *)malloc(sizeof(Genreplace_Req) + 1)) == NULL) return NULL; memset(reqptr, 0, sizeof(Genreplace_Req)); reqptr->addr = ip; reqptr->addr2 = addr2; reqptr->width = width; reqptr->height = height; // memcpy(&reqptr->ip, straddr, 15); // memcpy(&reqptr->iso, iso, 3);

    pkt = (void *)nanopkt(GENREPLACE_REQ, &rep_len, reqptr, sizeof(Genreplace_Req));
    

    nanopkt: char *nanopkt(int type, int *_len, void *extra, int extra_size) { NanoPkt *pkthdr; char *ret = NULL; int msg_sock = 0; int len = 0; void *data = NULL; void *out_data = NULL; int out_size = 0; char *ptr; int value=1000; int prio=1; char ipc[1024];

    out_data = (void *)malloc(sizeof(NanoPkt) + extra_size + 1);
    ptr = (char *)out_data;
    pkthdr = (NanoPkt *)ptr;
    ptr += sizeof(NanoPkt);
    
    pkthdr->type = type;
    pkthdr->len = sizeof(NanoPkt) + extra_size;
    
    if (extra_size) {
        memcpy(ptr, extra, extra_size);
        ptr += extra_size;
    }
    
    out_size = sizeof(NanoPkt) + extra_size;
    
    if ((msg_sock = nn_socket(AF_SP, NN_REQ)) < 0) goto end;
    //nn_setsockopt(msg_sock, NN_SOL_SOCKET, NN_RCVTIMEO, &value, sizeof(value));
    //nn_setsockopt(msg_sock, NN_SOL_SOCKET, NN_SNDTIMEO, &value, sizeof(value));
    for (prio = 1; prio < 5; prio++) {
        sprintf(ipc, "ipc:///tmp/%s%d.ipc", (type==ADREPLACE_REQ) ? "curl" : "adserver",    prio);
        nn_setsockopt (msg_sock, NN_SOL_SOCKET, NN_SNDPRIO, &prio, sizeof (int));
        nn_connect(msg_sock, ipc);
    }
    

    // if (nn_connect(msg_sock, "ipc:///tmp/adserver0.ipc") < 0) goto end; // doconnect(msg_sock,10); if (nn_send(msg_sock, out_data, out_size, 0) < 0) goto end;

    len = nn_recv(msg_sock, &data, NN_MSG, 0);
    
    *_len = len;
    
    if (data && len) {
        ret = malloc(len + 1);
        if (ret == NULL) return NULL; // fatal should exit...
        memcpy(ret, data, len);
        nn_freemsg(data);
    }
    

    end:; if (msg_sock) nn_close(msg_sock); return ret; }

    opened by mikeguidry 32
  • fixes #502 Assertion or Access Violation when calling nn_close while nn_recv blocks in separate thread

    fixes #502 Assertion or Access Violation when calling nn_close while nn_recv blocks in separate thread

    This PR replaces #502 by splitting out the test from tcp_shutdown into a new test called async_shutdown

    Again, for clarity, this PR fixes one type of bug on Windows, but then exposes a new failure mode downstream. The test -- but not the fix -- might expose further issues on *NIX systems.

    opened by JackDunaway 31
  • Receiving up published messages

    Receiving up published messages

    This seems to be affecting both C and Go code. The sender on the Pub side uses a scatter array from the C library with nn_sendmsg. The sub side was receiving using nn_recv. The data comes in, but there seems to be a constant memory leak when receiving packets. I was trying to convert over to nn_recvmsg, but I'm having a bit of trouble trying to setup to pull all data including hdr.msg_control data to make sure I clear the buffers. Opendns is blocking nanomsg.org, so I'm having a hard time with this at work. I can get data off the packets with nn_recvmsg, but I still leak memory and that is where I was trying to pull control data as well. In all cases, the receiver is making sure to empty the receive queue, but leaks still occur.

    opened by BillMcCroskey 30
  • An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.

    An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.

    On one machine I run a nanomsg based system (NNanoMsg, C#) on, I keep frequently hitting a generic Winsock error 10055. First, the system just exists instead of propagating the error higher up to let the application handle it properly. This is likely because asserts in release mode gets converted into exit call (DebugBreak is only called in debug).

    An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.
    [10055] (d:\git\nanomsg-0.5-beta\src\aio\usock_win.inc:474)
    

    Secondary, I'm wondering if there are any odd things in nanomsg that could cause this error to be triggered. I'm using it in an application with maybe 5 clients connecting, to 2-3 different tcp based protocol ports, and then a couple of one-off ports (pair sockets). On average I might use 40-50 sockets, not really enough to cause port exhaustion application side.

    The really weird thing is that even after I reboot the machine or kill off the application the system just won't recover from this error, and other application (teamviewer, tightvnc) seems to behave normally. So I'm wondering if there's any chance nanomsg could be corrupting some application memory, maybe affecting the winsock loaded memory or something?

    question 
    opened by phr34k 3
  • Avoiding null pointer dereference

    Avoiding null pointer dereference

    opened by binho1991 0
  • skip rpath during compilation and build.

    skip rpath during compilation and build.

    modified CMakeList.txt, skip rpath during compilation and build.

    opened by tongyishu 0
  • aborting in macOS

    aborting in macOS

    Hi,

    I'm trying to connect to "tcp://localhost:30000" from a sandboxed app in macOS. The send and rec timeouts have been set to 1000 - the app hangs without the timeouts. Having read some other issues I suspect that this represents a fundamental problem in nanomsg and that the advice would be to use nng instead. Can I confirm that is the best course of action?

    Many thanks,

    David

    Here's the stack trace (I think - I couldn't reconcile it fully with the source code) of the thread that brings down the app:

    Thread 22 crashed:
    
    #  1  0x000000010c0ec286 in  (merp + 0x0000000000003286) 0x0000000000000000
    #  2  0x00007fff6f8a05fd in __sigtramp + 0x0000001D (libsystem_platform.dylib + 0x00000000000035fd) 0x0000000000000000
    #  3  0x00000001132b6b8d in  ( + 0x0000000000000000) 0x000070000b3e8750
    #  4  0x00007fff6f776808 in _abort + 0x00000078 (libsystem_c.dylib + 0x000000000007f808) 0x000070000b3e8cc0
    #  5  0x0000000145757334 in _nn_err_errno + 0x00000000 (libnanomsg.5.1.0.dylib + 0x0000000000009334) 0x000070000b3e8d00
    #  6  0x0000000145755459 in _nn_usock_init_from_fd + 0x00000141 (libnanomsg.5.1.0.dylib + 0x0000000000007459) 0x000070000b3e8d10
    #  7  0x00000001457552f9 in _nn_usock_start + 0x00000022 (libnanomsg.5.1.0.dylib + 0x00000000000072f9) 0x000070000b3e8d40
    #  8  0x0000000145766cc4 in _nn_ctcp_handler + 0x000004E1 (libnanomsg.5.1.0.dylib + 0x0000000000018cc4) 0x000070000b3e8d60
    #  9  0x000000014575342e in _nn_ctx_leave + 0x00000022 (libnanomsg.5.1.0.dylib + 0x000000000000542e) 0x000070000b3e8ed0
    # 10  0x00000001457564c2 in _nn_worker_routine + 0x00000137 (libnanomsg.5.1.0.dylib + 0x00000000000084c2) 0x000070000b3e8f10
    # 11  0x0000000145758941 in _nn_thread_main_routine + 0x0000000D (libnanomsg.5.1.0.dylib + 0x000000000000a941) 0x000070000b3e8fa0
    # 12  0x00007fff6f8ac109 in __pthread_start + 0x00000094 (libsystem_pthread.dylib + 0x0000000000006109) 0x000070000b3e8fb0
    # 13  0x00007fff6f8a7b8b in _thread_start + 0x0000000F (libsystem_pthread.dylib + 0x0000000000001b8b) 0x000070000b3e8fd0
    
    awaiting feedback 
    opened by DangerMouseB 2
  • sub can not reconnect on Linux

    sub can not reconnect on Linux

    centos 7(server) : sub windows 10(client) : pub

    If the server network is disconnected for more than 20 seconds, when the network is restored, sub can not reconnect.

    awaiting feedback 
    opened by ren-zhihao 1
  • add IPv6 link-local support

    add IPv6 link-local support

    Adds support for IPv6 link-local to nanomsg. binding/connecting addresses such as 'tcp://[fe80::2%ctrl-iface]:9000' now works.

    opened by oengel 3
  • NN_REP socket and NN_RCVFD do not work on windows as expected

    NN_REP socket and NN_RCVFD do not work on windows as expected

    Hi, I am using event loop (glib) on windows and want to receive request on NN socket with REP patter on windows. I should receive requests from multiple workers, few workers may send request at the same moment of time.

    What I am doing:

    1. Create NN socket NN_REP
    2. Get NN_RCVFD with nn_getsockopt
    3. Listen on IN events on NN_RCVFD with glib
    4. When NN_RCVFD socket is triggered, I considered that some worker start sending data to me.
    5. Stop listening on NN_RCVFD.
    6. Call nn_recv with NN_DONTWAIT. If EAGAIN returned - call nn_recv in 50 milliseconds again (can do it multiple times). Otherwise I consider that received request.
    7. Process request
    8. When I got response to send back I start sending it with nn_send with NN_DONTWAIT
    9. If EAGAIN returned - call nn_send in 50 milliseconds, may do it multiple times until message is send
    10. After response sent - start listening on NN_RCVFD again

    This approach works well for me on Linux. But Windows at some point stops trigger NN_RCVFD when data is sent from worker. So worker send request fails with timeout.

    Socket protoc - NN_RCVFD, with IPC path

    I can provide a working example which reproduces the issue is needed

    awaiting feedback 
    opened by imuzychuk 1
  • build success as a 3rdparty

    build success as a 3rdparty

    Compile static library friendly with cmake.

    opened by yicm 0
  • survey pattern: Unexpected action: state=2 source=1 action=5(transports\tcp\atcp.c 228)

    survey pattern: Unexpected action: state=2 source=1 action=5(transports\tcp\atcp.c 228)

    my nanomsg version:1.1.5 my server app is survey mode, and when there are a lot connection coming in , the server crash and show like [Unexpected action: state=2 source=1 action=5(transports\tcp\atcp.c 228)] my clients is running all the time. when the number of client is about 1500 , everything is OK. when clients number is begin to be bigger , like 10 thousands,,, the exception happend!the server crash and exit! I think the clients may also crash and exit .

    Please help.

    My code:

    void init_survey_sock() { int sock; if ((sock = nn_socket(AF_SP, NN_SURVEYOR)) < 0) { fatal("nn_socket"); } int deadline = 15000; int rc = nn_setsockopt(sock, NN_SURVEYOR, NN_SURVEYOR_DEADLINE, &deadline, sizeof(deadline)); if (nn_bind(sock, SERVER_SUR_URL) < 0) { fatal("nn_bind"); } g_sock_sur = sock; }

    void SendActiveSurvey() { #define survey_topic "mytopic"

    my_printf("Sending survey request ...\n");
    int bytes = nn_send(g_sock_sur, survey_topic, strlen(survey_topic) + 1, 0);
    if (bytes < 0) {
    	fatal("nn_send");
    }
    my_printf("Receiving all response ...\n");
    
    for (;;) 
    {
    	char *buf = NULL;
    	int bytes = nn_recv(g_sock_sur, &buf, NN_MSG, 0);
    	if (bytes < 0) 
    	{
    		int nn_err = nn_errno();
    		if (nn_err == ETIMEDOUT)
    		{
    			my_printf("nn_recv() error code HIT deadline.\n");
    			break;
    		}
    		else if (nn_err == EFSM)
    		{
    			my_printf(" nn_recv->nn_errno()=EFSM returned. survey completed.\n");
    			break;
    		}
    		my_printf("Unknown nn_recv error code : %d  exit..\n", nn_err);
    		fatal("nn_recv");
    	}
    	//printf("Received:%s \n", buf);
    	process_survey_response(buf);
    	nn_freemsg(buf);
    }
    my_printf("Finished survey !\n");
    

    }

    process_survey_response(buf) 98989898

    { do some works }

    opened by Jackozoo 0
  • Not able to use with cmake FetchContent

    Not able to use with cmake FetchContent

    nanomsg does not build when used as a cmake subproject with FetchContent. The following error is observed:

    CMake Error: File /Users/<project-path>/bld/_deps/nanomsg-src/src/cmake/nanomsg-config.cmake.in does not exist. Call Stack (most recent call first): bld/_deps/nanomsg-src/src/CMakeLists.txt:395 (configure_package_config_file)

    This can be rectified using the following change at line number 395:

    configure_package_config_file(
    -    ${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in
    +    ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/${PROJECT_NAME}-config.cmake.in
         ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
         INSTALL_DESTINATION ${PACKAGE_INSTALL_DESTINATION}
         PATH_VARS CMAKE_INSTALL_PREFIX
    
    
    opened by renjipanicker 0
Releases(1.1.5)
  • 1.1.5(Oct 15, 2018)

    This release is a minor bug fix release, and includes some improvements to the CMake logic that should make incorporating nanomsg into larger projects easier.

    Source code(tar.gz)
    Source code(zip)
  • 1.1.4(Jun 7, 2018)

    This release is primarily a bug-fix release for Windows platforms, but it also adds support for building on Android.

    The main change in this release is a fix for the IPC transport on Windows, which was subject to crashing if the remote peer breaks messages into smaller pieces. As some other SP implementations do this to avoid data copies, this fix is very important.

    A fix for leaking handles on Windows is included.

    Support for compilation on Android using the NDK and the bundled cmake and toolchain file from Android is now present.

    Source code(tar.gz)
    Source code(zip)
  • 1.1.3(May 23, 2018)

    This is the last planned release for nanomsg. (New effort is focued on the NNG project -- see github.com/nanomsg/nng for details.)

    The following changes are present:

    • CMake exported target, easing inclusion in larger projects (see demos/CMakeLists.txt for an example)
    • Windows no longer uses a single fixed TCP port for eventfd (this should improve reliability)
    • Fix for an assertion failure in efd_unsignal
    • The ABI version is separate from the library version now.
    • Fixed a crash when calling nn_term without first opening a socket.
    • Fix for building Windows tests on case-sensitive file systems.
    • CI/CD improvements: switch to CircleCI, and use CodeCov for coverage analysis.

    Please let us know if there are any significant problems with this release; thanks!

    Source code(tar.gz)
    Source code(zip)
  • 1.1.2(Nov 6, 2017)

  • 1.1.1(Nov 6, 2017)

    ** THIS RELEASE HAS A COMPILE BUG ON LINUX. Use 1.1.2 INSTEAD **

    This is a bug fix release for 1.1.0.

    Two main issues are resolved:

    • nanomsg no longer wakes up every 100 msec even when no I/O is pending

      Some users noticed that nanomsg was performing wakeups regardless of whether I/O was available or not. This had a detrimental effect on power usage.

    • nanomsg no longer crashes when accept fails on Windows

      In some circumstances an outstanding accept() operation that got aborted (for example due to the socket closing) could wind up crashing the application. This was a race, and it is closed now.

    We also fixed a few compilation warnings on Windows.

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Oct 17, 2017)

    This release is primarily a bug fix release for nanomsg, and rolls up a number of stability improvements, particularly for the inproc transport. A port to support Windows Subsystem for Linux is provided as well. There are no changes to the ABI.

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0-rc1(Oct 13, 2017)

    This is the first release candidate of 1.1.0. This release is primarily a bug fix release for nanomsg, and rolls up a number of stability improvements, particularly for the inproc transport. A port to support Windows Subsystem for Linux is provided as well. There are no changes to the ABI.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Jun 10, 2016)

    This is the first production release of nanomsg. We consider that this version is stable and suitable for use in production by all nanomsg users.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-rc2(Jun 6, 2016)

    This corrects (we hope) the problem of "Unknown" versions being reported when building out of source. It also corrects building on systems using MSys2, and adds a few demo programs to the source tree that developers may find useful.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-rc1(Jun 3, 2016)

    This is the first release candidate for 1.0.0.

    The changes in this release from earlier releases include:

    • cmake is now mandatory (but a configure wrapper script is present to help)
    • nn_bind() performs the bind() and listen() synchronously (accept is async still) reporting errors back to the caller
    • a new socket option, NN_MAXTTL, is available to configure the maximum "hops" a message may go through before it is dropped (each device traversal is a hop). This is enforced for REP and RESPONDENT protocols, breaking loops.
    • Because cmake doesn't do it automatically, Linux users may need to run ldconfig manually to update the ld.so cache.

    The ABI is the same as v0.9 - 5.0.0.

    At this point we are not expecting to make any code changes prior to the 1.0.0 production release. We are contemplating release of binary packages for Windows, MacOS X, and both RedHat and Debian on x86. We hope that this is the very last release of nanomsg before the production 1.0.0 release.

    Source code(tar.gz)
    Source code(zip)
  • 0.9-beta(May 15, 2016)

Owner
nanomsg
Nanomsg Project
nanomsg
ZeroMQ core engine in C++, implements ZMTP/3.1

ZeroMQ Welcome The ZeroMQ lightweight messaging kernel is a library which extends the standard socket interfaces with features traditionally provided

The ZeroMQ project 7.2k Sep 17, 2021
Mirror of Apache Kafka

Apache Kafka See our web site for details on the project. You need to have Java installed. We build and test Apache Kafka with Java 8, 11 and 15. We s

The Apache Software Foundation 19.9k Sep 20, 2021
Kue is a priority job queue backed by redis, built for node.js.

Kue Kue is no longer maintained Please see e.g. Bull as an alternative. Thank you! Kue is a priority job queue backed by redis, built for node.js. PRO

Automattic 9.3k Sep 17, 2021
Distributed Task Queue (development branch)

Version: 5.1.0b1 (singularity) Web: https://docs.celeryproject.org/en/stable/index.html Download: https://pypi.org/project/celery/ Source: https://git

Celery 17.9k Sep 15, 2021
Simple job queues for Python

RQ (Redis Queue) is a simple Python library for queueing jobs and processing them in the background with workers. It is backed by Redis and it is desi

RQ 7.9k Sep 22, 2021
Disque is a distributed message broker

Disque, an in-memory, distributed job queue Disque is an ongoing experiment to build a distributed, in-memory, message broker. Its goal is to capture

Salvatore Sanfilippo 7.8k Sep 15, 2021
a little task queue for python

a lightweight alternative. huey is: a task queue (2019-04-01: version 2.0 released) written in python (2.7+, 3.4+) clean and simple API redis, sqlite,

Charles Leifer 3.7k Sep 24, 2021
Micro second messaging that stores everything to disk

Chronicle Queue Contents Table of Contents Contents About Chronicle Software What is Chronicle Queue Java Docs Usage More benchmarks Downloading Chron

Chronicle Software : Open Source 2.4k Sep 15, 2021