Skip to content

Instantly share code, notes, and snippets.

@kchawla-pi
Created January 17, 2023 21:05
Show Gist options
  • Save kchawla-pi/851fba4fe0d61313c760011632a5d10a to your computer and use it in GitHub Desktop.
Save kchawla-pi/851fba4fe0d61313c760011632a5d10a to your computer and use it in GitHub Desktop.
Errors encountered while using Memphis-Broker
nats: encountered error
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 1301, in _select_next_server
await self._transport.connect(
File "/root/.local/lib/python3.10/site-packages/nats/aio/transport.py", line 118, in connect
r, w = await asyncio.wait_for(
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
return fut.result()
File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
transport, _ = await loop.create_connection(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1078, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 6666), [Errno 99] Cannot assign requested address
nats: encountered error
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 1301, in _select_next_server
await self._transport.connect(
File "/root/.local/lib/python3.10/site-packages/nats/aio/transport.py", line 118, in connect
r, w = await asyncio.wait_for(
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
return fut.result()
File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
transport, _ = await loop.create_connection(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1078, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 6666), [Errno 99] Cannot assign requested address
nats: encountered error
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 1301, in _select_next_server
await self._transport.connect(
File "/root/.local/lib/python3.10/site-packages/nats/aio/transport.py", line 118, in connect
r, w = await asyncio.wait_for(
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
return fut.result()
File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
transport, _ = await loop.create_connection(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1078, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 6666), [Errno 99] Cannot assign requested address
nats: encountered error
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 1301, in _select_next_server
await self._transport.connect(
File "/root/.local/lib/python3.10/site-packages/nats/aio/transport.py", line 118, in connect
r, w = await asyncio.wait_for(
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
return fut.result()
File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
transport, _ = await loop.create_connection(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1078, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 6666), [Errno 99] Cannot assign requested address
nats: encountered error
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 1301, in _select_next_server
await self._transport.connect(
File "/root/.local/lib/python3.10/site-packages/nats/aio/transport.py", line 118, in connect
r, w = await asyncio.wait_for(
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
return fut.result()
File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
transport, _ = await loop.create_connection(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1078, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 6666), [Errno 99] Cannot assign requested address
nats: encountered error
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 1301, in _select_next_server
await self._transport.connect(
File "/root/.local/lib/python3.10/site-packages/nats/aio/transport.py", line 118, in connect
r, w = await asyncio.wait_for(
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
return fut.result()
File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
transport, _ = await loop.create_connection(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1078, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 6666), [Errno 99] Cannot assign requested address
nats: encountered error
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 1301, in _select_next_server
await self._transport.connect(
File "/root/.local/lib/python3.10/site-packages/nats/aio/transport.py", line 118, in connect
r, w = await asyncio.wait_for(
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
return fut.result()
File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
transport, _ = await loop.create_connection(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1078, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 6666), [Errno 99] Cannot assign requested address
nats: encountered error
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 1301, in _select_next_server
await self._transport.connect(
File "/root/.local/lib/python3.10/site-packages/nats/aio/transport.py", line 118, in connect
r, w = await asyncio.wait_for(
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
return fut.result()
File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
transport, _ = await loop.create_connection(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1078, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 6666), [Errno 99] Cannot assign requested address
nats: encountered error
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 1301, in _select_next_server
await self._transport.connect(
File "/root/.local/lib/python3.10/site-packages/nats/aio/transport.py", line 118, in connect
r, w = await asyncio.wait_for(
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
return fut.result()
File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
transport, _ = await loop.create_connection(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1078, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 6666), [Errno 99] Cannot assign requested address
nats: encountered error
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 1301, in _select_next_server
await self._transport.connect(
File "/root/.local/lib/python3.10/site-packages/nats/aio/transport.py", line 118, in connect
r, w = await asyncio.wait_for(
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
return fut.result()
File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
transport, _ = await loop.create_connection(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1078, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 6666), [Errno 99] Cannot assign requested address
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/memphis/memphis.py", line 108, in connect
self.broker_manager = await broker.connect(servers=self.host+":"+str(self.port),
File "/root/.local/lib/python3.10/site-packages/nats/__init__.py", line 44, in connect
await nc.connect(servers, **options)
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 478, in connect
raise e
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 468, in connect
await self._select_next_server()
File "/root/.local/lib/python3.10/site-packages/nats/aio/client.py", line 1268, in _select_next_server
raise errors.NoServersError
nats.errors.NoServersError: nats: no servers available for connection
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/project/user_endpoints/app/message_broker.py", line 53, in <module>
asyncio.run(example())
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/opt/project/user_endpoints/app/message_broker.py", line 44, in example
await produce(
File "/opt/project/user_endpoints/app/message_broker.py", line 18, in produce
await broker.connect(
File "/root/.local/lib/python3.10/site-packages/memphis/memphis.py", line 120, in connect
raise MemphisConnectError(str(e)) from e
import logging
import asyncio
from memphis import Headers, Memphis
logger = logging.getLogger(__name__)
async def produce(
station_name: str,
producer_name: str,
message: str,
header_info: dict | None = None,
msg_id: str | None = None
):
broker = Memphis()
try:
await broker.connect(
host="localhost",
username="root",
connection_token="memphis",
)
producer = await broker.producer(station_name=station_name, producer_name=producer_name)
headers = Headers()
header_info = header_info or {}
for k,v in header_info.items():
headers.add(k, v)
if msg_id:
await producer.produce(message=bytearray(message, "utf-8"), headers=headers, msg_id=msg_id)
else:
await producer.produce(message=bytearray(message, "utf-8"), headers=headers)
except:
raise
finally:
await broker.close()
async def example():
station_name = "temp-station1"
producer_name = "scratch_8_run3"
message = "scratch8msg"
header_info = {"key1": "value1", "key2": "value2"}
await produce(
station_name=station_name,
producer_name=producer_name,
message=message,
header_info=header_info
)
if __name__ == '__main__':
asyncio.run(example())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment