Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 23 12:20
    jeikabu opened #1175
  • Jan 21 17:47
    gdamore closed #78
  • Jan 21 17:44
    gdamore labeled #24
  • Jan 21 17:43
    gdamore milestoned #192
  • Jan 21 17:43
    gdamore labeled #192
  • Jan 21 17:42
    gdamore milestoned #253
  • Jan 21 17:42
    gdamore labeled #253
  • Jan 21 17:30
    gdamore labeled #1171
  • Jan 21 16:28
    gdamore labeled #1172
  • Jan 21 16:27
    gdamore labeled #1174
  • Jan 21 16:27
    gdamore opened #1174
  • Jan 21 16:26
    gdamore labeled #1173
  • Jan 21 16:26
    gdamore opened #1173
  • Jan 21 16:23
    gdamore opened #1172
  • Jan 21 16:21
    gdamore closed #64
  • Jan 21 16:02
    gdamore milestoned #446
  • Jan 21 15:59
    gdamore closed #609
  • Jan 21 15:59
    gdamore milestoned #15
  • Jan 21 15:55
    gdamore milestoned #1132
  • Jan 21 15:55
    gdamore milestoned #1117
rahulraj80
@rahulraj80

@gdamore I will test with combinations of extra "/" and revert. And will also check and revert on using the TCP socket.

However, when NNGCat.exe is the client and PyNNG is the server (same code as above in reply to Cody), I get repeated connects and disconnect - so NNGCat is connecting over IPC - only it does not wait for messages.

$ python moduleC.py listen ipc://CSharp_listener_pipe_001
~~~~got connection from CSharp_listener_pipe_001
~~~~goodbye for now from CSharp_listener_pipe_001

<continuous loop>

~~~~got connection from CSharp_listener_pipe_001
~~~~goodbye for now from CSharp_listener_pipe_001
rahulraj80
@rahulraj80
@codypiersall Please ignore the script above. Have stripped it down to the essentials:
import argparse
import pynng
import trio
import sys

run_sync = trio.to_thread.run_sync

async def send_eternally(sock):
    while True:
        stuff = await run_sync(input, cancellable=True)
        for pipe in sock.pipes:
            print("{} Sent to :{}:".format(stuff,str(pipe)))
            await pipe.asend(("{}".format(stuff)).encode())

async def recv_eternally(sock):
    while True:
        msg = await sock.arecv_msg()
        content = msg.bytes.decode()
        print('Received :{!r}:'.format(content))


async def main():
    p = argparse.ArgumentParser(description=__doc__)
    p.add_argument(
        'mode',
        help='Whether the socket should "listen" or "dial"',
        choices=['listen', 'dial'],
    )
    p.add_argument(
        'addr',
        help='Address to listen or dial; e.g. tcp://127.0.0.1:13134',
    )
    args = p.parse_args()

    with pynng.Pair1(polyamorous=True) as sock:
        async with trio.open_nursery() as n:
            if args.mode == 'listen':

                def pre_connect_cb(pipe):
                    addr = str(pipe.remote_address)
                    print('~~~~got connection from {}'.format(addr))

                def post_connect_cb(pipe):
                    addr = str(pipe)
                    print('Finally connected to {}'.format(addr))

                def post_remove_cb(pipe):
                    addr = str(pipe.remote_address)
                    print('~~~~goodbye for now from {}'.format(addr))

                sock.add_pre_pipe_connect_cb(pre_connect_cb)
                sock.add_post_pipe_connect_cb(post_connect_cb)
                sock.add_post_pipe_remove_cb(post_remove_cb)

                sock.listen(args.addr)

            else:
                sock.dial(args.addr)

            n.start_soon(recv_eternally, sock)
            n.start_soon(send_eternally, sock)


if __name__ == '__main__':
    try:
        trio.run(main)
    except KeyboardInterrupt:
        # that's the way the program *should* end
        pass
rahulraj80
@rahulraj80
This is the almost exactly the base Pair1 example for PyNNG.
rahulraj80
@rahulraj80

@gdamore : Using 2 or 3 "/" behave exactly the same for me for IPC.

When using TCP - the connect and disconnect behaviour is the same, just the port number keeps changing between tries.

$ python moduleD.py listen tcp://127.0.0.1:8034 ~~~~got connection from 127.0.0.1:65114
~~~~goodbye for now from 127.0.0.1:65114
~~~~got connection from 127.0.0.1:65115
~~~~goodbye for now from 127.0.0.1:65115
~~~~got connection from 127.0.0.1:65116
~~~~goodbye for now from 127.0.0.1:65116
For reference - when I dial from another PyNNG script (same Pair1 example as above) : and send "Hi" from that, and reply with "Hello" from this listener:
$ python moduleD.py listen tcp://127.0.0.1:8034 ~~~~got connection from 127.0.0.1:65124
Finally connected to <pynng.nng.Pipe object at 0x00000125AB524688>
Received :'Hi':
Hello
Hello Sent to :<pynng.nng.Pipe object at 0x00000125AB524688>:
rahulraj80
@rahulraj80

So - @gdamore @codypiersall : I am not sure if this helps - I tried sniffing the pipe to see what is the difference in what is being sent and received.

When Connecting -
On the left is PyNNG with a PyNNG Pair1, and on the right is NNGCat.exe with nngPy :

image.png

And when sending a message (hello1234 sent on left, ABC1234ABC sent on right):

image.png

rahulraj80
@rahulraj80
While connecting, the headers are different and also before sending the message. It seems, NNGCat speaks a slightly different dialect. (I am big newbie, so apologies in advance).
And wish a HUGELY Successful and Happy New Year to both of you, and all our other members!!!!
Cody Piersall
@codypiersall
Hi @rahulraj80, I think you're using incompatible protocols in your C# and Python code, maybe. Your pynng code was using pairv1, and your nngpy code above was using req0. What protocol is your C# code using?
Garrett D'Amore
@gdamore
More likely pairv1 vs pairv0.
Version 1 and version 2 are not compatible.
Well, we have the captures, so I can check. Gimme a second.
So it looks like one side is trying to use REPv0, and the other is using PAIRv1.
Make sure you're using --pair1 as an argument to nngcat.
rahulraj80
@rahulraj80

Aaah!! So they were really speaking different dialects! 🤦‍♂️🤦‍♂️🤦‍♂️
C# code was from Github/Jeikabu - NNG which unfortunately does not do Pair1. :-( ... Just saw Garrett's version. Looks like I will have to rewrite it in C#. :-(

Thanks for the guidance both of you!!

rahulraj80
@rahulraj80
Done.... Thanks for the guidance. Working now. :-)
Nate Kent
@neachdainn
@gdamore The NNG_*_VERSION definitions still indicate that it is v1.1.1
Garrett D'Amore
@gdamore
Oops. Thanks for noticing.
fpvision
@fpvision
Hi, is it possible to compose a list of active listners and dialers and connected peers -? I'm trying to build a monitoring tool, for a complex nng network , I just need a hint of where to start.
Garrett D'Amore
@gdamore
For NNG there is nng_stat(3) that should help with this
evan kahn
@wormyrocks
Hi Garrett, was just updating my NNG project to track the latest updates and noticed that something in win_thread.c breaks mingw-w64 compilers. I remember having fixed this in my own branch months ago, and you fixed it properly shortly thereafter, but it looks like it's broken again.
libnng.a builds properly (with scary warnings) but nng_testlib, many of the tests, and my project that depends on it fail to build (with error messages related to said warnings)
Here's stderror from building the static lib w/ compiler warnings (you can ignore the first few lines)
evan kahn
@wormyrocks
and here are the linker errors from building tests etc
evan kahn
@wormyrocks
Additional question, just checked out the changelogs for v1.2.x - does the existence of non-SP implementations mean that there is a switch to enable a text-mode websocket connection? That is one of the only changes I'm maintaining on my fork (the other one being the HTTP virtual host issue we worked through here a few weeks ago).
Thanks as always!
Garrett D'Amore
@gdamore
I'll have a look. mingw is always a pain because they don't have the full set of symbols.
And from what I can tell they don't document what their missing, or even what they have.
There is no switch for text mode websocket yet -- mostly because I haven't got to it yet.
ciclonite
@ciclonite
Hi
ciclonite
@ciclonite
Thanks a lot for nng Garret! I'm new with nng, and i'm interested on architecture benihd nng. Other than reference manual, there is another starting point?
Garrett D'Amore
@gdamore
Unfortunately, not a lot written up. You can see the RATIONALE document.
The whole design behind the aio framework is probably something that deserves a design document in it's own right.
ciclonite
@ciclonite
Thanks for reply, i'm not a c superskilled programmer like you,
and i'm worried about using nng in a wrong way ;).
Garrett D'Amore
@gdamore
I wouldn't worry about that - you can use the example programs to help you -- you really shouldn't have to concern yourself with the internals.
ciclonite
@ciclonite
Ok, thanks a lot, i'm starting with nng async..
I have just a curiosity, which IDE are you using for coding nng? (if you use one). Thanks again for your patience.
Garrett D'Amore
@gdamore
I've used both visual studio code and these days I'm using CLion.
The original work was probably done mostly in vi.
Actually it might have been sublime text. I switch IDEs periodically.
Right now I'm mostly liking CLion, but it isn't free.
(I'm using GoLand for mangos ... also not free...)
ciclonite
@ciclonite
I've also used clion and it's a great product! But i'm a fan of eclipse CDT with cmake4eclipse... The only drawback is damn slow... :) Sorry for OT. Have a nice day
Garrett D'Amore
@gdamore
No worries... i don't use Java anymore (for decades now), so I've never really looked at eclipse
ciclonite
@ciclonite
Thanks Garret!
Garrett D'Amore
@gdamore
Sure. Btw, I prefer that folks use Discord.. gitter is buggy as heck these days. See https://discordapp.com/invite/S7pyeva