nng | nanomsg-next-generation -- light-weight brokerless messaging | Build Tool library
kandi X-RAY | nng Summary
kandi X-RAY | nng Summary
NNG, like its predecessors nanomsg (and to some extent ZeroMQ), is a lightweight, broker-less library, offering a simple API to solve common recurring messaging problems, such as publish/subscribe, RPC-style request/reply, or service discovery. The API frees the programmer from worrying about details like connection management, retries, and other common considerations, so that they can focus on the application instead of the plumbing. NNG is implemented in C, requiring only C99 and CMake to build. It can be built as a shared or a static library, and is readily embeddable. It is also designed to be easy to port to new platforms if your platform is not already supported.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of nng
nng Key Features
nng Examples and Code Snippets
Community Discussions
Trending Discussions on nng
QUESTION
I was given an API for some library (nng to be exact) it has a C-like interface for allocating and deallocating a message object:
...ANSWER
Answered 2022-Mar-07 at 09:19You only have to pass the allocated pointer and the custom deleter to std::shared_ptr
, for example:
QUESTION
I'm using NNG as my inter-server msg-queue.
Background:
- I'm implementing a pair of long time background services, those are communicating with NNG;
- Protocol: pair0 @ tcp;
- The payload message occurs maybe a second, or maybe a day;
My question: Does NNG automatically transmit a "Heartbeat" msg peroidically to each peer to keep the TCP connection alive, if there is no producing msg for a specific time duration?
If NOT, should I do "HeartBeat" by myself?
BTW, this is the first time I use NNG. I don't know whether there is a official/populated support forum of it, so I ask my question here. If such a forum exists, pls. tell me. Thanks!
...ANSWER
Answered 2022-Jan-07 at 05:19Welcome to the NNG & distributed-processing
We can, under any circumstances send zero-sized "app-level" heartbeats, if we wish our transport be rock solid proven to be RTO
Yet, the NNG uses nn_setsockopt()
-configurator options { ... | NN_RECONNECT_IVL | NN_RECONNECT_IVL_MAX | ... }
to fine-tune low-level details, including the failed / closed sockets' reconnect management
The full call signature is :
QUESTION
I'd like to use nanomsg
/nng
as the communication basis of a fully distributed peer-to-peer multi-node network, to help construct the dynamic ability of topological discovery and maintenance. Now I get stuck in its Golang package mangos
.
The same work has been done in Python and pynng (which is a python binding for nanomsg), but when I use Go and invoke the corresponding methods by mangos instead, their behaviors are totally different. The puzzle is mainly threefold:
- The bus-type-Socket's Recv() acts in a blocking mode by default and seems not to be configurable to the non-blocking mode. Documents says:
OptionRecvDeadline is the time until the next Recv times out. The value is a time.Duration. Zero value may be passed to indicate that no timeout should be applied. A negative value indicates a non-blocking operation. By default there is no timeout.
I tried a negative value accordingly, but Recv()
was still blocking. What else should I do? and how to understand the difference between "Zero-timeout" and "non-blocking"?
- The
dialer
returned by(s *socket) NewDialer(...)
seems to linger on after callingdialer.Close()
, since an error will occur when calling a nextdialer.Dial()
reporting it's still "address in use". But when I tried toClose()
thedialer
again, error occurs as well reporting it's already closed. I also tried different combinations of the following options, but all the attempts failed
ANSWER
Answered 2021-Jun-30 at 14:33I don't usually monitor stackoverflow or reddit for questions like this -- we do have a discord channel (link from the mangos and NNG home pages), as well as a mailing list.
Having said that, let me see if I can help (I'm the author for both NNG and mangos):
- OptionRecvDeadline is supported for bus. However, you're correct that it doesn't support non-blocking mode with a negative value, instead the negative value is treated the same as zero, and acts as blocking. This is a documentation bug. To achieve a logical non-blocking, use the value "1", which means one nanosecond, and that will logically equate to non-blocking, although the granularity may be limited by the scheduler latency. (In this case it would be like doing a "go close(channel); <-channel" -- very nearly non-blocking.
I'll see about fixing the documentation.
Calling Close() on the dialer is the right thing to do. It will linger until the pipes are closed, which it does automatically. It is possible that your use of a very short redial time might confound this -- I'll be honest in saying that I had not considered tiny redial times -- usually it's bad form to do this because it means that if the peer is not available your code will spin hard on the processor trying to reconnect. I usually recommend at minimum a 10 millisecond retry interval cap. (mangos.OptionMaxReconnectTime)
I think you're seeing the effect of queueing, but I'm not 100% certain -- I'd need to see a test case reproducing this. Definitely the bus protocol is best effort delivery, and if there are no connected peers then the message is dropped on the floor. (Just rechecked that to be certain.)
QUESTION
I am trying to make a c-program server that publishes images via nng, and a python client via pynng that subscribes to the images.
For some reason i cannot connect these 2 parts and I dont know why. C/C++-program compiles and runs fine and so does python program, but something is published on the C/C++-program, nothing is recieved on the python client. Client and server runs on the same machine. Here is my C/C++-code for the server:
...ANSWER
Answered 2020-May-08 at 15:23You have to subscribe to topics on your subscribing socket, or you won't receive anything. In order to receive all messages, subscribe to the empty string:
QUESTION
I'm working on a "server" thread, which takes care of some IO calls for a bunch of "clients".
The communication is done using pynng v0.5.0, the server has its own asyncio loop.
Each client "registers" by sending a first request, and then loops receiving the results and sending back READY messages.
On the server, the goal is to treat the first message of each client as a registration request, and to create a dedicated worker task which will loop doing IO stuff, sending the result and waiting for the READY message of that particular client.
To implement this, I'm trying to leverage the Context feature of REP0 sockets.
Side notes
I would have liked to tag this question with nng and pynng, but I don't have enough reputation.
Although I'm an avid consumer of this site, it's my first question :)
I do know about the PUB/SUB pattern, let's just say that for self-instructional purposes, I chose not to use it for this service.
Problem:
After a few iterations, some READY messages are intercepted by the registration coroutine of the server, instead of being routed to the proper worker task.
Since I can't share the code, I wrote a reproducer for my issue and included it below.
Worse, as you can see in the output, some result messages are sent to the wrong client (ERROR:root:: worker/client mismatch, exiting.
).
It looks like a bug, but I'm not entirely sure I understand how to use the contexts correctly, so any help would be appreciated.
Environment:
- winpython-3.8.2
- pynng v0.5.0+dev (46fbbcb2), with nng v1.3.0 (ff99ee51)
Code:
...ANSWER
Answered 2020-Apr-18 at 07:24After digging into the sources of both nng and pynng, and confirming my understanding with the maintainers, I can now answer my own question.
When using a context on a REP0 socket, there are a few things to be aware of.
As advertised, send/asend() is guaranteed to be routed to the same peer you last received from.
The data from the next recv/arecv() on this same context, however, is NOT guaranteed to be coming from the same peer.
Actually, the underlying nng call to rep0_ctx_recv()
merely reads the next socket pipe with available data, so there's no guarantee that said data is coming from the same peer than the last recv/send pair.
In the reproducer above, I was concurrently calling arecv() both on a new context (in the Server._new_client_handler()
coroutine), and on each worker context (in the Server._worker()
coroutine).
So what I had previously described as the next request being "intercepted" by the main coroutine was merely a race condition.
One solution would be to only receive from the Server._new_client_handler()
coroutine, and have the workers only handle one request. Note that in this case, the workers are no longer dedicated to a particular peer. If this behavior is needed, the routing of incoming requests must be handled at application level.
QUESTION
This is a Sinhalese Transliteration Convertor. It returns wrong output. Eg: If I enter m, it must return ම්, but it reruns ම්
. I don't know why it gives additional ්
The same code is working well in codepen, but not in Blogspot.
The JS is
vowelsUni[0]='ඌ'; vowels[0]='oo'; vowelModifiersUni[0]='ූ'; vowelsUni[1]='ඕ'; vowels[1]='o\\)'; vowelModifiersUni[1]='ෝ'; vowelsUni[2]='ඕ'; vowels[2]='oe'; vowelModifiersUni[2]='ෝ'; vowelsUni[3]='ආ'; vowels[3]='aa'; vowelModifiersUni[3]='ා'; vowelsUni[4]='ආ'; vowels[4]='a\\)'; vowelModifiersUni[4]='ා'; vowelsUni[5]='ඈ'; vowels[5]='Aa'; vowelModifiersUni[5]='ෑ'; vowelsUni[6]='ඈ'; vowels[6]='A\\)'; vowelModifiersUni[6]='ෑ'; vowelsUni[7]='ඈ'; vowels[7]='ae'; vowelModifiersUni[7]='ෑ'; vowelsUni[8]='ඊ'; vowels[8]='ii'; vowelModifiersUni[8]='ී'; vowelsUni[9]='ඊ'; vowels[9]='i\\)'; vowelModifiersUni[9]='ී'; vowelsUni[10]='ඊ'; vowels[10]='ie'; vowelModifiersUni[10]='ී'; vowelsUni[11]='ඊ'; vowels[11]='ee'; vowelModifiersUni[11]='ී'; vowelsUni[12]='ඒ'; vowels[12]='ea'; vowelModifiersUni[12]='ේ'; vowelsUni[13]='ඒ'; vowels[13]='e\\)'; vowelModifiersUni[13]='ේ'; vowelsUni[14]='ඒ'; vowels[14]='ei'; vowelModifiersUni[14]='ේ'; vowelsUni[15]='ඌ'; vowels[15]='uu'; vowelModifiersUni[15]='ූ'; vowelsUni[16]='ඌ'; vowels[16]='u\\)'; vowelModifiersUni[16]='ූ'; vowelsUni[17]='ඖ'; vowels[17]='au'; vowelModifiersUni[17]='ෞ'; vowelsUni[18]='ඇ'; vowels[18]='/\a'; vowelModifiersUni[18]='ැ'; vowelsUni[19]='අ'; vowels[19]='a'; vowelModifiersUni[19]=''; vowelsUni[20]='ඇ'; vowels[20]='A'; vowelModifiersUni[20]='ැ'; vowelsUni[21]='ඉ'; vowels[21]='i'; vowelModifiersUni[21]='ි'; vowelsUni[22]='එ'; vowels[22]='e'; vowelModifiersUni[22]='ෙ'; vowelsUni[23]='උ'; vowels[23]='u'; vowelModifiersUni[23]='ු'; vowelsUni[24]='ඔ'; vowels[24]='o'; vowelModifiersUni[24]='ො'; vowelsUni[25]='ඓ'; vowels[25]='I'; vowelModifiersUni[25]='ෛ'; nVowels=26; specialConsonantsUni[0]='ං'; specialConsonants[0]=/\\n/g; specialConsonantsUni[1]='ඃ'; specialConsonants[1]=/\\h/g; specialConsonantsUni[2]='ඞ'; specialConsonants[2]=/\\N/g; specialConsonantsUni[3]='ඍ'; specialConsonants[3]=/\\R/g; //special characher Repaya specialConsonantsUni[4]='ර්'+'\u200D'; specialConsonants[4]=/R/g; specialConsonantsUni[5]='ර්'+'\u200D'; specialConsonants[5]=/\\r/g; consonantsUni[0]='ඬ'; consonants[0]='nnd'; consonantsUni[1]='ඳ'; consonants[1]='nndh'; consonantsUni[2]='ඟ'; consonants[2]='nng'; consonantsUni[3]='ථ'; consonants[3]='Th'; consonantsUni[4]='ධ'; consonants[4]='Dh'; consonantsUni[5]='ඝ'; consonants[5]='gh'; consonantsUni[6]='ඡ'; consonants[6]='Ch'; consonantsUni[7]='ඵ'; consonants[7]='ph'; consonantsUni[8]='භ'; consonants[8]='bh'; consonantsUni[9]='ශ'; consonants[9]='sh'; consonantsUni[10]='ෂ'; consonants[10]='Sh'; consonantsUni[11]='ඥ'; consonants[11]='GN'; consonantsUni[12]='ඤ'; consonants[12]='KN'; consonantsUni[13]='ළු'; consonants[13]='Lu'; consonantsUni[14]='ද'; consonants[14]='dh'; consonantsUni[15]='ච'; consonants[15]='ch'; consonantsUni[16]='ඛ'; consonants[16]='kh'; consonantsUni[17]='ත'; consonants[17]='th'; consonantsUni[18]='ට'; consonants[18]='t'; consonantsUni[19]='ක'; consonants[19]='k'; consonantsUni[20]='ඩ'; consonants[20]='d'; consonantsUni[21]='න'; consonants[21]='n'; consonantsUni[22]='ප'; consonants[22]='p'; consonantsUni[23]='බ'; consonants[23]='b'; consonantsUni[24]='ම'; consonants[24]='m'; consonantsUni[25]='ය'; consonants[25]='\\u005C' + 'y'; consonantsUni[26]='ය'; consonants[26]='Y'; consonantsUni[27]='ය'; consonants[27]='y'; consonantsUni[28]='ජ'; consonants[28]='j'; consonantsUni[29]='ල'; consonants[29]='l'; consonantsUni[30]='ව'; consonants[30]='v'; consonantsUni[31]='ව'; consonants[31]='w'; consonantsUni[32]='ස'; consonants[32]='s'; consonantsUni[33]='හ'; consonants[33]='h'; consonantsUni[34]='ණ'; consonants[34]='N'; consonantsUni[35]='ළ'; consonants[35]='L'; consonantsUni[36]='ඛ'; consonants[36]='K'; consonantsUni[37]='ඝ'; consonants[37]='G'; consonantsUni[38]='ඨ'; consonants[38]='T'; consonantsUni[39]='ඪ'; consonants[39]='D'; consonantsUni[40]='ඵ'; consonants[40]='P'; consonantsUni[41]='ඹ'; consonants[41]='B'; consonantsUni[42]='ෆ'; consonants[42]='f'; consonantsUni[43]='ඣ'; consonants[43]='q'; consonantsUni[44]='ග'; consonants[44]='g'; //last because we need to ommit this in dealing with Rakaransha consonantsUni[45]='ර'; consonants[45]='r'; specialCharUni[0]='ෲ'; specialChar[0]='ruu'; specialCharUni[1]='ෘ'; specialChar[1]='ru'; //specialCharUni[2]='්ර'; specialChar[2]='ra';
function startText() { var s,r,v; text = document.txtBox.box1.value; //special consonents for (var i=0; i//consonents + HAL for (var i=0; i // End -->
...ANSWER
Answered 2020-Mar-01 at 00:21for (var i=0; i
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nng
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page