changed mqtt to rabbitMQ test file

This commit is contained in:
2025-10-23 20:56:09 +03:00
parent 71621896eb
commit 5532e89038
3 changed files with 22 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ import paho.mqtt.client as paho
import paho.mqtt.enums as paho_enums
class vqeMqttBroker:
def __init__(self, broker_address, broker_port, username="", password="", use_tls=True, max_connection_attempts=30):
def __init__(self, broker_address, broker_port, username="correct", password="any", use_tls=True, max_connection_attempts=30):
self.server = broker_address
self.port = broker_port
self.client = paho.Client(callback_api_version=paho.CallbackAPIVersion.VERSION2, client_id="my_python_client", reconnect_on_failure=True)

20
source/rabbitmq_test.py Normal file
View File

@@ -0,0 +1,20 @@
import pika
import ssl
print
context = ssl.create_default_context()
context.verify_mode = ssl.CERT_REQUIRED
ssl_options= pika.SSLOptions(context=context, server_hostname="rabbitmq.deowl.ru")
credential = pika.PlainCredentials("admin", "admin")
try:
connection = pika.BlockingConnection(pika.ConnectionParameters('rabbitmq.deowl.ru', virtual_host='/', port=5671, ssl_options=ssl_options, credentials=credential))
channel = connection.channel()
print("good")
except pika.exceptions.AMQPConnectionError as e:
print(f"Connection error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")