changed mqtt to rabbitMQ test file
This commit is contained in:
2
main.py
2
main.py
@@ -3,7 +3,7 @@ from time import sleep, time
|
||||
|
||||
from multiprocessing import Process, Queue
|
||||
import source.vqe as vqe
|
||||
import source.mqtt as mqtt
|
||||
import project.source.archive.mqtt as mqtt
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
@@ -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
20
source/rabbitmq_test.py
Normal 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}")
|
||||
Reference in New Issue
Block a user