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

Incompatibility with asyncua library #42

Open
ts4iot opened this issue Mar 20, 2023 · 0 comments
Open

Incompatibility with asyncua library #42

ts4iot opened this issue Mar 20, 2023 · 0 comments

Comments

@ts4iot
Copy link

ts4iot commented Mar 20, 2023

I try to use the tb_device_mqtt library together with the asyncronous opc-ua library asyncua and asyncio.Queue().

With the standard paho-mqtt library the sending of the data works fine. With tb_device_mqtt library it is not working.

The relevant part of the code looks like this:
p_plc is the asyncua client
q_queue is an async.Queue

    async with g_plc:
	    await subscribe()
	    while g_running:
		    if(not g_queue.empty()):
			    g_logger.info("Queue size start: %d" % g_queue.qsize())	
			    while(not g_queue.empty()):
				    send_data(await g_queue.get())
		    await g_plc.check_connection()
		    await asyncio.sleep(0.001)
	    await asyncio.sleep(2)

The send_data function sends the data to the thingsboard server.

With paho-mqtt I send the data with:

	ret = g_rcc_mqtt.publish('v1/devices/me/telemetry', data, 1)
	g_logger.info(ret)

With tb_device_mqtt I send the data with:

	result = g_rcc_mqtt.send_telemetry(data)
	success = result.get() == TBPublishInfo.TB_ERR_SUCCESS
	g_logger.info(success)

With tb_device_mqtt I get after some seconds the exception: Message publish failed: The client is not currently connected.
Is there an example that shows how to use tb_device_mqtt library inside asyncio code.

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

1 participant