Open drivard opened 4 years ago
Hi, Did you able to solve this problem, I am also facing same. Thanks.
I recently used this and it worked, while testing connectivity to a new instance.
pika==0.13.0
send.py
import ssl
credentials = pika.credentials.PlainCredentials(username='********', password='********')
parameters = pika.ConnectionParameters(
host='***********.rmq.cloudamqp.com',
port=5671,
virtual_host='********',
credentials=credentials,
ssl=True
)
connection = pika.BlockingConnection(parameters)
# Create the channel and the queue
channel = connection.channel()
channel.queue_declare(queue='hello', durable=True)
# publish the message
channel.basic_publish(exchange='',
routing_key='hello',
body='Hello World!')
print(" [x] Sent 'Hello World!'")
connection.close()
receive.py
import pika
import ssl
credentials = pika.credentials.PlainCredentials(username='********', password='********')
parameters = pika.ConnectionParameters(
ssl=True,
host='********.rmq.cloudamqp.com',
port=5671,
virtual_host='********',
credentials=credentials
)
connection = pika.BlockingConnection(parameters)
# Create the channel and the queue
channel = connection.channel()
channel.queue_declare(queue='hello', durable=True)
# consume the queue
def callback(ch, method, properties, body):
print(" [x] Received %r" % body)
channel.basic_consume(callback,
queue='hello',
no_ack=True)
print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
@drivard thank you
FYI: ssl=True
does not work with version 1.3.2
of pika. I get TypeError: unexpected kwargs: {'ssl': True}
. Currently, haven't found a way to get this working.
@johnfaucette right, check this example that I'm trying to add to the Pika docs: https://github.com/pika/pika/pull/1436/commits/0975526996fcbd008c1ac39851b1801f73c4c3ca.
If you don't want to mess with "ssl.SSLContext" you can use URLParameters
Thanks @johanrhodin . That example helps a lot 👍 .
Hi,
It would be really appreciated to get the example of a working connection using the amqps scheme. I am currently trying to achieve that using the pika library but I always get the error:
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)
I cannot tell if it is related to the Comodo CA or the OS lacking the intermediate CA or any of the usual ssl issues, since I tried many combinaisons as well as downloading the intermediate CA cert from comodo to ensure that it is known by my OS.
The connection sample I used is:
I am using python from mac os catalina and I used brew to install python. Python 3.7.5 in an isolated virtualenv with only pika installed.
pika==1.1.0
Thanks for your help.