Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPC PUB-SUB protocol doesn't work #62

Open
peetonn opened this issue Oct 24, 2017 · 1 comment
Open

IPC PUB-SUB protocol doesn't work #62

peetonn opened this issue Oct 24, 2017 · 1 comment

Comments

@peetonn
Copy link

peetonn commented Oct 24, 2017

Trying to test with IPC protocol, but messages are never received:

publisher:

>>> from nanomsg import Socket, PUB, SUB
>>> s = Socket(PUB)
>>> s.bind('ipc://test')
<BindEndpoint socket <Socket fd 0, connected to [], bound to ['ipc://test']>, id 1, address 'ipc://test'>
>>> s.send(b'test\n')

subscriber:

>>> from nanomsg import Socket, PUB, SUB
>>> s = Socket(SUB)
>>> s.connect('ipc://test')
<ConnectEndpoint socket <Socket fd 0, connected to ['ipc://test'], bound to []>, id 1, address 'ipc://test'>
>>> s.recv()

Is there anything Python-specific for IPC I'm missing out here? I tried nnpy - it doesn't work either.

@ollvai
Copy link

ollvai commented Mar 16, 2018

Seems to be working just fine, you're just missing the subscribe definition:

>>> import nanomsg
>>> nanomsg.__version__
'1.0'
>>> from nanomsg import Socket, PUB, SUB
>>> p = Socket(PUB)
>>> p.bind(b"ipc://test")
<BindEndpoint socket <Socket fd 0, connected to [b'ipc://test'], bound to []>, id 1, addresss b'ipc://test'>
>>> p.send(b"test")
>>> from nanomsg import Socket, PUB, SUB, SUB_SUBSCRIBE
>>> s = Socket(SUB)
>>> s.connect(b"ipc://test")
<ConnectEndpoint socket <Socket fd 0, connected to [], bound to [b'ipc://test']>, id 1, addresss b'ipc://test'>
>>> s.set_string_option(SUB, SUB_SUBSCRIBE, b'')
>>> s.recv()
b'test'

Tested with Windows 7. Checkout nanomsg tests for more examples: https://github.com/tonysimpson/nanomsg-python/tree/master/tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants