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

Reconnect + send == error #25

Open
madkote opened this issue Mar 6, 2020 · 2 comments
Open

Reconnect + send == error #25

madkote opened this issue Mar 6, 2020 · 2 comments

Comments

@madkote
Copy link

madkote commented Mar 6, 2020

Hi @pedrokiefer ,

Following example is basic.

  • in the loop, client sends message and sleeps for a some period.
  • reconnecting is infinite with reconnect_max_attempts=-1
  • ActiveMQ is started with docker-compose in another terminal

Steps to reproduce

  • set value SLEEP_VALUE to 2.0
  • start ActiveMQ with docker-compose
  • start script (below) with receiver and producer
  • let it run for a few seconds to make sure all messages are arriving
  • stop ActiveMQ with docker-compose
  • start ActiveMQ with docker-compose
  • script will terminate

Problem

  • The reconnect is performing good as such (just increase the SLEEP_VALUE, e.g. to 12.0
  • The real issue occurs when calling methods of the client and there is no connection.

Questions:

  • this was an intention to handle connection error in methods by the user of library?
  • I guess a work around is to let user retry few more times and handle the error.
import sys
import logging
import time
import asyncio
import aiostomp

async def on_message(frame, message):
    print('on_message:', message)
    return True

async def report_error(error):
    print('report_error:', error)

async def run():
    SLEEP_VALUE = 12.0
    client = aiostomp.AioStomp('localhost', 61613, reconnect_max_attempts=-1, error_handler=report_error)
    client.subscribe('/queue/channel', handler=on_message)
    await client.connect(username='guest', password='guest')
    try:
        while True:
            try:
                print('>>> send')
                client.send('/queue/channel', body=u'Thanks %s' % time.time())
                print('<<< sleep')
                await asyncio.sleep(SLEEP_VALUE)
            except KeyboardInterrupt:
                break
    finally:
        client.close()

def main(args):
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run())
    loop.run_forever()

if __name__ == '__main__':
    logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
    main(sys.argv)
@jgcb00
Copy link

jgcb00 commented Oct 3, 2022

Same for me !
The first send works well but as soon as the following one, which is the next line of code, there is the same issue, no connection and therefore nothing go through

@madkote
Copy link
Author

madkote commented Oct 4, 2022

Same for me ! The first send works well but as soon as the following one, which is the next line of code, there is the same issue, no connection and therefore nothing go through

the project seems to be dead. I am not using ActiveMQ now.

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