Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 12 18:07
    norsd opened #995
  • Sep 06 17:35
    vk-coder closed #994
  • Sep 06 14:56
    vk-coder opened #994
  • Sep 04 15:30
    fpvision edited #993
  • Sep 04 15:23
    fpvision opened #993
  • Aug 28 16:36
    maingig opened #992
  • Aug 26 15:03
    gdamore labeled #991
  • Aug 26 06:55
    wildwild opened #991
  • Aug 24 22:09
    gdamore closed #988
  • Aug 24 22:09
    gdamore labeled #988
  • Aug 24 22:08
    gdamore closed #990
  • Aug 24 22:07
    gdamore labeled #990
  • Aug 24 21:01
    kv-gits edited #990
  • Aug 24 20:52
    kv-gits opened #990
  • Aug 20 11:29
    pzoltowski opened #989
  • Aug 19 21:58
    pzoltowski opened #988
  • Aug 19 14:24
    firthm01 opened #987
  • Aug 15 02:51
    qtcdxxyuc opened #986
  • Aug 12 16:05

    gdamore on bug954

    (compare)

  • Aug 12 16:04

    gdamore on fix976

    (compare)

Cody Piersall
@codypiersall
And I think he was using string as a synonym for bytes though, and was more pointing out the difference between the zeromq way and nng way.
bsdis
@bsdis
@codypiersall yes exactly - i guess i am just noticing differences since i have not used nng before and only used zmq - so probably its a matter of getting used to the differences
bsdis
@bsdis
what am i doing wrong here? why am i not recieving anything?
from trio import run
from pynng import Pair0

#########
# Run below in terminal 1

async def runrec():
    address = "tcp://0.0.0.0:5554"
    with Pair0(listen=address) as s0:
        print(await s0.arecv())
run(runrec)

#########
# Run below in terminal 2

import pynng
address = "tcp://0.0.0.0:5554"
socket = pynng.Pair0(dial=address)
socket.send(b'hello')
is it not possible to run async on server and sync on client?
bsdis
@bsdis
weird...i had to restart machine and then it worked
bsdis
@bsdis

Hi, i often get errors like this one:

Traceback (most recent call last):
  File "/home/hh/anaconda3/lib/python3.7/site-packages/pynng/nng.py", line 1231, in _nng_pipe_cb
    pipe = sock._pipes[pipe_id]
KeyError: 1674867871

What causes this type of errors?

bsdis
@bsdis

Is it maybe because i am discarding socket everytime i send message? I do this

def send_message(op, data):
    address = f"tcp://{conf.MCU_SERVER}:{conf.stream_ports['cmd']}"
    with pynng.Pair0(dial=address) as socket:
        socket.send(bson.dumps({'OP': op, 'data' : data}))
        return socket.recv().decode()

If thats the cause - then what should be done to keep the connection alive when used in a disconnected environment such as a webserver?

bsdis
@bsdis
Is anybody in here?
bsdis
@bsdis
ahh i think this is what i am experiencing codypiersall/pynng#40
bsdis
@bsdis
Hmm ok - i tried to compile nng from source on branch pipe-notify-race according to codypiersall/pynng#40 and use pynng compiled with that version of the library - but i still get the dropped sockets/race conditions or whatever is wrong. Is there any way to fix this KeyError: 1674867871 issue i wonder?
Garrett D'Amore
@gdamore
I'm not sure as I haven't really looked at the python code. But you should not discard the socket after receiving a message.
Cody Piersall
@codypiersall

@bsdis there are a couple races going on related to pipe events. Some are pynng related and some are in nng itself. In particular, nng can send pipe events in the wrong order for short-lived sockets. When that happens, the post pipe remove callback can get called before the post-pipe-connect callback, and then pynng tries to access a pipe that it is no longer keeping track of. The PR that I made for nng I believe has unintended side effects, and there needs to be a meta issue, but I haven't gotten around to creating the issue yet.

If the socket has a longer life span, you shouldn't see this issue.

Garrett D'Amore
@gdamore
I have some thoughts on fixing the life cycle callbacks, I just haven't gotten enough cycles to work on it. Honestly, I had hoped that there would be very few consumers of this API, but it turns out to be more popular than I had planned.
kv-gits
@kv-gits
I found that callback runs in thread. If one callback is blocking(waiting for send msg) can other callback (receiving new msg) be invoked in other thread? So is it possible two running callbacks at the same time?
kv-gits
@kv-gits
Does new callback call spawns new thread?
kv-gits
@kv-gits
Also Is it possible async read write with only one ctx and aio?
Cody Piersall
@codypiersall
FWIW I was trying to reproduce what I was seeing in pynng using a straight C reproducer, and I couldn't. I may be wrong about the root issue being in nng, but then I ran out of time to track it down further. I'm still planning on checking this out more.
Scottars
@Scottars
Hello, everyone, nanomsg is new to me, but i am working on a project which is to send data from stm32 to pc. is it possible that stm32 could use nanomsg or zeroMQ??? I have been stuck for two days and don't know where to begin
Cody Piersall
@codypiersall
If you can get Linux to run on you STM32 there's a chance you could get nng to run on it as well. You're pretty seriously space constrained on the stm32 though. I'm guessing you're not booting into Linux on it currently?
If you want nng to run without an OS you'll have to make a custom "platform" (I think, Garrett please correct me if I'm wrong). You can see the functions that would need to be implemented here: https://github.com/nanomsg/nng/blob/master/src/core/platform.h
Alternatively you could just implement whichever protocols you need directly by going through the RFCs: https://github.com/nanomsg/rfcs, https://github.com/nanomsg/nanomsg/tree/master/rfc
Cody Piersall
@codypiersall
I'm guessing you'll be using tcp?
Garrett D'Amore
@gdamore
@Scottars STM32 is going to be very very constrained. I don't think it's realistic to run something like NNG on it. I think you'd have trouble even getting TCP to operate in such a small factor -- typically you're going to use some kind of serial bus for connectivity. You could do that to an agent which runs NNG on the PC, but from your STM32 you're probably better off with RS-232 or something and custom code on the PC.
@codypiersall be advised that the threading architecture in pynng (and in Python itself) may play a role in reproduction of your test cases. I'm not entirely convinced it isn't still an issue in NNG.
@kv-gits callbacks make use of a common set of threads -- we don't spawn a new one, but use one of the ones in the pool. If you have lots and lots of callbacks, this means that they can wait to get a free thread.
Generally you can reuse a single AIO for read/write, but only if you do either just read, or just write, at any given point in time. You can use a single ctx with multiple AIOs though.
kv-gits
@kv-gits
@gdamore so I understand that for async pair radio we need one socket, one ctx and two aio, right?
Garrett D'Amore
@gdamore
RIght
kv-gits
@kv-gits
Thanks
Pierre Yager
@zedalaye
Hi ! I'm a user of ZeroMQ/Zyre. How hard would it be to build a Zyre like implementation with nng ?
Alex ⚡
@Alex-CodeLab
@Scottars MQTT was made for such small boards (perhaps try it with micropython).
also, Hi everyone :) . short intro: I've used ZMQ a lot in the past, now testing Nanomsg and websocket options.
Richard Markiewicz
@thenextman

Hello folks; I'm trying to get the PID of a peer on an ipc socket. I'm checking the option ipc:peer-pid which works well on Windows and Linux. The documentation says:

This option is only available on Windows, Linux, and certain other systems

It looks like it should work on macOS:

https://github.com/nanomsg/nng/blob/v1.1.1/src/platform/posix/posix_ipcconn.c#L385

And, indeed, LOCAL_PEERPID is defined on my system. But I get NNG_ENOTSUP. Should this work?

anemo
@swengineer
@gdamore excuse me, can nn_bind() be used for SO_REUSEADDR, which means multiple process can nn_bind() one port?
Richard Markiewicz
@thenextman

Hello folks; I'm trying to get the PID of a peer on an ipc socket. I'm checking the option ipc:peer-pid which works well on Windows and Linux. The documentation says:

This option is only available on Windows, Linux, and certain other systems

It looks like it should work on macOS:

https://github.com/nanomsg/nng/blob/v1.1.1/src/platform/posix/posix_ipcconn.c#L385

And, indeed, LOCAL_PEERPID is defined on my system. But I get NNG_ENOTSUP. Should this work?

Further to this, I hacked on the code a little and see that on my macOS system, I fall into the initial #if defined(NNG_HAVE_GETPEEREID) and return early. By moving the code around and allowing the #if defined(LOCAL_PEERPID) code block to run, I can successfully get the peer PID. So I'm wondering why the code is structured in this way, since the field is available (LOCAL_PEERPID is since OS X 10.8). But the header does say it's only for Windows, Linux and SunOS. Would a PR on this be accepted?

anemo
@swengineer
I mean use SO_REUSEPORT for nanomsg
delioda79
@delioda79
Hello chaps, is with great happiness that even though I've changed company and we are using kafka for al asynchronous stuff, I'm building something where I will push for using mangos, and I'm prototyping the code now, and it will be just in-process at the moment, but I hope they will like the idea so we could do somethng also over TCP
delioda79
@delioda79
actually got n issue
I'm trying to create a pub socket with inproc and I listen to "inproc://my-adress"
can't listen on pub socket: %saddress in use
delioda79
@delioda79
BTW fixed
BUt I have a question, why does mangos have dependency on go-winio if I'm using mac?
evan kahn
@wormyrocks
@gdamore I've been working on a project that has RPC-style access to an NNG rep0 server, on ipc:/// and ws://localhost transports, basically so I can establish the same level of access both via a browser frontend and a native app communicating over ipc. So I hand-rolled a partial implementation in pure js of the Req protocol, and it seems to work well enough for my needs, but I'm running into an issue I'm not sure how to start debugging:
Basically Chromium browsers can send an arbitrary amount of data (i've tested up to a gigabyte at a time) but Webkit browsers crap out and completely disconnect the websocket after sending about 1.2MB.
I think this has to do with the nng rep0 socket implementation since I've tested it with a raw node.js websocket receiver and the size limit doesn't apply. But i think the webkit implementation of ws, as opposed to chromium, frames the messages in a way that nng doesn't understand - a quick wireshark trace confirms this but I'm not sure how to debug further
Once I extricate my req0 implementation from the application-specific code I'm happy to share it here as this seems like something a bunch of people have asked for, but I'm curious if you think that my assessment of the webkit issue is accurate, and if there are any easy steps to take that might fix it
delioda79
@delioda79
@gdamore I'm trying to do some tests with some code using mangos sockets, but even though if the cod eworks, it seems impossibe to make it work in teh tests, I also made a simple test function where I have a publisher and a subscriber running in different go routimes, the subscriber dials into the inproc address of the publisher, the publisher sends messages but the subscriber never receives them
is mangos v2
delioda79
@delioda79
Actually I found out again, but I'm trying to get how it works now, because in v1 it wasn;t like that. I need to subscribe using the optionsubscribe, but I can't get how this subscription works, like to a topic I guess
Sorry, never mind, I couldn;t find teh docs but I found them, BTW very nice mangs 2