Show Table of Contents
11.7. Setting Connection Options
There are two different ways to set connection options. The first is to do it in the Connection constructor:
- Python
connection = Connection("localhost:5672", reconnect = True, reconnect_urls = "amqp:tcp:127.0.0.1:5674", heartbeat = 1) try: connection.open()- C++
Connection connection("localhost:5672", "{reconnect: true, reconnect_urls:'amqp:tcp:127.0.0.1:5674', reconnect:true, heartbeat: 1}"); try { connection.open();- .NET/C#
Connection connection= new Connection("localhost:5672", "{reconnect: true, reconnect_urls:'amqp:tcp:127.0.0.1:5674', reconnect:true, heartbeat: 1}"); try { connection.Open();
The second approach is to do it through the Connection properties:
- Python
connection = Connection("localhost:5672") connection.reconnect = True try: connection.Open()- C++
Connection connection("localhost:5672"); connection.setOption("reconnect", true); try { connection.open();- .NET/C#
Connection connection = new Connection("localhost:5672"); connection.SetOption("reconnect", true); try { connection.Open();

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.