Giter Site home page Giter Site logo

moleculer-client's People

Contributors

caiofilus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

moleculer-client's Issues

Got timed out with the given example

Hi @CaioFilus ,
tried to bring the moleculer-client example work with this ServiceBroker
Following the example I got

In [1]: from moleculer_client import MoleculerClient
In [4]: moleculer = MoleculerClient(node_id='python-node', moleculer_nodeID="master", url='nats://127.0.0.1:4222')

In [5]: print(moleculer.discover())
---------------------------------------------------------------------------
timeout                                   Traceback (most recent call last)
<ipython-input-5-ea42592b8850> in <module>
----> 1 print(moleculer.discover())

/opt/miniconda3/envs/moleculerPy/lib/python3.6/site-packages/moleculer_client/moleculer_client.py in discover(self, broadcast)
     81         else:
     82             self.nc.publish(MoleculerCommands.DISCOVER.format(self.node), payload=json.dumps(body).encode())
---> 83         self.nc.wait(count=1)
     84         return result['payload']
     85

/opt/miniconda3/envs/moleculerPy/lib/python3.6/site-packages/pynats/client.py in wait(self, count)
    217         total = 0
    218         while True:
--> 219             command, result = self._recv(MSG_RE, PING_RE, OK_RE)
    220             if command is MSG_RE:
    221                 self._handle_message(result)

/opt/miniconda3/envs/moleculerPy/lib/python3.6/site-packages/pynats/client.py in _recv(self, *commands)
    259
    260     def _recv(self, *commands: Pattern[bytes]) -> Tuple[Pattern[bytes], Match[bytes]]:
--> 261         line = self._readline()
    262
    263         command = self._get_command(line)

/opt/miniconda3/envs/moleculerPy/lib/python3.6/site-packages/pynats/client.py in _readline(self, size)
    275
    276         while True:
--> 277             line = self._socket_file.readline()
    278             if not line:
    279                 raise NATSReadSocketError()

/opt/miniconda3/envs/moleculerPy/lib/python3.6/socket.py in readinto(self, b)
    584         while True:
    585             try:
--> 586                 return self._sock.recv_into(b)
    587             except timeout:
    588                 self._timeout_occurred = True

timeout: timed out

It seems the self.nc.wait(count=1) causes this error.

Meanwhile, using nats-python==0.7.0 to interact with the nats broker works well

In [6]: from pynats import NATSClient
   ...:
   ...: with NATSClient(url='nats://127.0.0.1:4222', socket_timeout=5) as client:
   ...:     # Connect
   ...:     client.connect()
   ...:
   ...:     # Subscribe
   ...:     def callback(msg):
   ...:         print(f"Received a message with subject {msg.subject}: {msg}")
   ...:
   ...:     client.subscribe(subject="MOL.DISCOVER.master", callback=callback)
   ...:
   ...:     # Publish a message
   ...:     client.publish(subject="MOL.DISCOVER.master", payload=b"test-payload")
   ...:
   ...:     # wait for 1 message
   ...:     client.wait(count=1)
   ...:
Received a message with subject MOL.DISCOVER.master: NATSMessage(sid=0, subject='MOL.DISCOVER.master', reply='', payload=b'test-payload')

Here the last line client.wait(count=1) does not cause this error.
Thanks for helping me address this error.

Environment

  • Python 3.6.13
  • moleculer-client 0.1.6
  • nats-python 0.7.0

How to find python node

Hi Caio,
I am currently implementing this moleculer client in python environment, so I wonder how to obtain the node-id=python-node which is required to work:
moleculer = MoleculerClient(node_id='python-node', moleculer_nodeID="engineering-tools-pc-644", url='nats://localhost:4222')

The other parameters a doing good and I guess this the only one missing.
May you pleasae help me thru...
Thanks
Eduardo

Molecule Client for Python [NATS running remotely]

Hi Caio, how're you doing, hope well,
I have been successful in communicating Moleculer as a client for python. all works fine when NATS transporter is running over the same computer than both. the problem is when I tried to reach NATS over other machine.
Have you got any suggestions on how to make it sorted?
Thanks one more time.
Eduardo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.