<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Problems to use MQTT with RabbitMQ broker</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/118847/problems-to-use-mqtt-with-rabbitmq-broker</link><description>Hi everyone, 
 
 I&amp;#180;m work on a project were i have to stablish a mqtt connection with a RabbitMQ broker thats have user/pass auth and tls without certificate validate. My application works fine with a lot of others brokers (Nordic, Eclipse, Mosquitto</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 24 Feb 2025 13:50:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/118847/problems-to-use-mqtt-with-rabbitmq-broker" /><item><title>RE: Problems to use MQTT with RabbitMQ broker</title><link>https://devzone.nordicsemi.com/thread/524358?ContentTypeID=1</link><pubDate>Mon, 24 Feb 2025 13:50:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c431c80e-c52d-4980-bf58-7dcf589a0488</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Felipe,&lt;br /&gt;&lt;br /&gt;Thank you for additional information and provided photos.&lt;br /&gt;&lt;br /&gt;There is a way to change&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/nrfxlib-apis-latest/page/group_nrf_socket_so_sec_handshake_timeouts.html"&gt;DTLS handshake timeout values&lt;/a&gt;&amp;nbsp;in the nrfxlib. You can look also at&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrfxlib/nrf_modem/doc/sockets/socket_options_func.html#socket_options"&gt;socket options&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/nrfxlib-apis-latest/page/group_nrf_socket_api_ga8dcadacb89103e90e796de190814f1be.html#ga8dcadacb89103e90e796de190814f1be"&gt;nrf_setsockopt()&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems to use MQTT with RabbitMQ broker</title><link>https://devzone.nordicsemi.com/thread/523987?ContentTypeID=1</link><pubDate>Fri, 21 Feb 2025 04:26:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ce475e7-c07b-41a6-98d1-c98fa64daf37</guid><dc:creator>Felipe Dantas</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;About simcards, normally we&amp;acute;ve been used 3 mobile network operators, that are main operators in Brazil, and this is: Claro, Tim and Vivo. We also used simcards of tow virtual mobile operators: Eseye and Virtueyes. Booth two virtual mobile operators can access the network of Tim, Vivo and Claro. The most stable network is the Tim.&lt;br /&gt;This problem afect all devices that we have in test with our customer, but the device connected with Tim simcard is the only one that get connect with success (but sometime they also can fail). All devices try to connect with the same broker, but with different simcards how i described above.&lt;br /&gt;About log files, how i said, i don&amp;acute;t have direct access to server, but the IT maintainer two photos of server screen thats show the connection proccess of some devices. My apologies by send raw images by this way, but is the only information that i can get now.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Aditional information: When we try connect with this broker without TLS (on port 1883) we always can connect with success to this broker.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;acute;ve been sended the photos by link below.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;&lt;br /&gt;Felipe Dantas&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://drive.google.com/drive/folders/17w8oeGRxpnstA2T3_GMrcrlImgIZz3zp?usp=sharing"&gt;https://drive.google.com/drive/folders/17w8oeGRxpnstA2T3_GMrcrlImgIZz3zp?usp=sharing&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems to use MQTT with RabbitMQ broker</title><link>https://devzone.nordicsemi.com/thread/523864?ContentTypeID=1</link><pubDate>Thu, 20 Feb 2025 10:38:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5968cdd0-dba8-4b19-8ddc-9c5719d0318c</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Felipe,&lt;br /&gt;&lt;br /&gt;Which mobile network does your device connect to? &lt;br /&gt;Which SIM card do you use?&lt;br /&gt;Is this problem observed on a single device or on multiple devices?&lt;br /&gt;Do all affected devices connect to the same network?&lt;br /&gt;Do you have any devices that connect to the same network as affected devices, but without problems?&lt;/p&gt;
[quote user="Felipe Dantas"]The server log of rabbitmq show that the 9160 connect with broker and itself disconnect by&amp;nbsp; something like &amp;quot;tls handshake timeout&amp;quot;.&amp;nbsp;[/quote]
&lt;p&gt;Can you share your RabbitMQ server log and your application log?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems to use MQTT with RabbitMQ broker</title><link>https://devzone.nordicsemi.com/thread/523781?ContentTypeID=1</link><pubDate>Wed, 19 Feb 2025 22:49:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9f4dfd6-5e0f-4bed-aba3-5b8e7d966406</guid><dc:creator>Felipe Dantas</dc:creator><description>&lt;p&gt;Hi Dejans,&lt;/p&gt;
&lt;p&gt;I couldn&amp;#39;t read everything, but I think the main point is that the handshake timeout occurs on the 9160 side and not on the server side. As I mentioned, I don&amp;#39;t have access to change or request changes to our customer&amp;#39;s server implementation, since it is already in a large production environment and works normally for the applications that our customer already had. Our customer&amp;#39;s IT maintainer only informed us that based on the server logs he concluded that our hardware does not wait long enough to complete the handshake process and when the server tries to continue the process, the hardware has already closed the connection on its own. It is worth mentioning that with the simcard of some mobile operators the 9160 can deposit the data on server, and from what we can see, these operators simply have more stable networks, with lower pings. I made a really weird code that assembles the MQTT packets with TLS in a raw way with posix and native sockets and it works in 100% of the time, but as I said, it is an absurd solution to use in a production environment. I believe that what would solve this type of solution in a true and definitive way would be something that allowed adjusting these parameters through the code natively (or something like that). One more time, some help to understand what are occurs here with this scenary are very helpfull.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Felipe&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems to use MQTT with RabbitMQ broker</title><link>https://devzone.nordicsemi.com/thread/522693?ContentTypeID=1</link><pubDate>Wed, 12 Feb 2025 15:57:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c2fa36d-6200-427c-b1b3-fcb095781c6b</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Felipe,&lt;br /&gt;&lt;br /&gt;Thank you for additional information.&lt;/p&gt;
[quote user="Felipe Dantas"]My main question now is: why it´s work with python and java but not in 9160? (Maybe a more bigger latency introduced by mobile network?)[/quote]
&lt;p&gt;The issue could potentially happen due to increased latency. We would need a log for further investigation of the error.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I have found some similar issues online. You could look at the links below just to see if there is anything that might be causing the issue in your case. Here are some links:&lt;br /&gt;&lt;a href="https://www.rabbitmq.com/docs/troubleshooting-networking"&gt;rabbitmq network troubleshooting network connectivity&lt;/a&gt;&lt;br /&gt;&lt;a href="https://github.com/rabbitmq/rabbitmq-server/issues/1683"&gt;rabbitmq server issues&lt;/a&gt;&lt;br /&gt;&lt;a href="https://stackoverflow.com/questions/36454573/handshake-timeout-error-with-ssl-connection-in-rabbitmq"&gt;handshake timeout error&lt;/a&gt;&lt;br /&gt;&lt;a href="https://groups.google.com/g/rabbitmq-users/c/v2y-GMYMjfE"&gt;TLS authentication handshake timeout error&lt;/a&gt;&lt;br /&gt;&lt;a href="https://github.com/rabbitmq/rabbitmq-server/issues/11171"&gt;log TLS handshake timeouts&lt;/a&gt;&lt;br /&gt;&lt;a href="https://github.com/ninenines/ranch/issues/336"&gt;silent drop of TLS connection&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user="dejans"]Is your issue similar to what was discussed&amp;nbsp;&lt;a href="https://rabbitmq-users.narkive.com/V1Q1TXo8/increasing-the-handshake-timeout"&gt;here&lt;/a&gt;?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Have you considered reaching out to&amp;nbsp;&lt;a href="https://discord.com/invite/VwWnkG3GWy"&gt;RabbitMQ Community&lt;/a&gt;&amp;nbsp;on Discord?[/quote]
&lt;p&gt;Have you looked at these links?&lt;br /&gt;&lt;br /&gt;Are any of provided links useful in your case?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems to use MQTT with RabbitMQ broker</title><link>https://devzone.nordicsemi.com/thread/522679?ContentTypeID=1</link><pubDate>Wed, 12 Feb 2025 14:43:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f35b2187-e21d-4990-be29-483abefd2688</guid><dc:creator>Felipe Dantas</dc:creator><description>&lt;p&gt;Hi Dejans,&lt;/p&gt;
&lt;p&gt;Other aditional information is that the servers of my customer works fine with yours own applications and devices and i don&amp;acute;t have access or any possibility to change anything in her. Only think that i can do now is search what in my application cause this behavior. We have tested this broker with a python and java script run on desktop and both works fine.&lt;br /&gt;&lt;br /&gt;Is a hard problem to solve because 9160 don&amp;acute;t log nothing about that. In 9160 log, we can see entire MQTT process occurs without any error, but none data appears on broker.&lt;br /&gt;&lt;br /&gt;The server log of rabbitmq show that the 9160 connect with broker and itself disconnect by&amp;nbsp; something like &amp;quot;tls handshake timeout&amp;quot;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;My main question now is: why it&amp;acute;s work with python and java but not in 9160? (Maybe a more bigger latency introduced by mobile network?)&lt;/p&gt;
&lt;p&gt;This is the python scrip that i used to test and it work and can send data corretly for my customer&amp;acute;s broker:&lt;br /&gt;&lt;pre class="ui-code" data-mode="python"&gt;import socket
import ssl
import time
import logging

# logging config
logging.basicConfig(
    filename=&amp;quot;mqtt_test.log&amp;quot;,
    level=logging.DEBUG,
    format=&amp;quot;%(asctime)s - %(levelname)s - %(message)s&amp;quot;
)

# Add a handker to show logs on terminal
console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
formatter = logging.Formatter(&amp;quot;%(asctime)s - %(levelname)s - %(message)s&amp;quot;)
console.setFormatter(formatter)
logging.getLogger().addHandler(console)

# MQTT broker config
BROKER = &amp;quot;putyourbrokerurlhere&amp;quot;  # broker address. Changed do hide customer informations
PORT = 8883  # Port of mqtt broker with tls
CLIENT_ID = &amp;quot;mqtt_tester&amp;quot;
USERNAME = &amp;quot;putyouruserhere&amp;quot;  # broker username. Changed do hide customer informations
PASSWORD = &amp;quot;putyourpasshere&amp;quot;  # broker password. Changed do hide customer informations
TOPIC = &amp;quot;test/mqtt&amp;quot;
MESSAGE_TEMPLATE = &amp;quot;Teste de conex&amp;#227;o MQTT - Contador: {}&amp;quot;
QOS = 1  # QoS 1

# Funtion to encode remain lenght
def encode_remaining_length(length):
    encoded_bytes = bytearray()
    while True:
        encoded_byte = length % 128
        length //= 128
        # If still have data, define most significant bit = 1
        if length &amp;gt; 0:
            encoded_byte |= 128
        encoded_bytes.append(encoded_byte)
        if length == 0:
            break
    return encoded_bytes

# Funtion to build CONNECT packet with auth
def create_connect_packet(client_id, username, password):
    packet = bytearray()
    packet.extend(b&amp;quot;\x10&amp;quot;)  # Type of packet CONNECT
    variable_header = b&amp;quot;\x00\x04MQTT\x04\xC2\x00&amp;lt;&amp;quot;  # Flags adjusted to auth
    payload = bytes([0, len(client_id)]) + client_id.encode()
    payload += bytes([0, len(username)]) + username.encode()
    payload += bytes([0, len(password)]) + password.encode()
    remaining_length = encode_remaining_length(len(variable_header) + len(payload))
    packet.extend(remaining_length)
    packet.extend(variable_header)
    packet.extend(payload)
    return packet

# Funtion to build PUBLISH packer with QoS 1
def create_publish_packet(topic, message):
    packet = bytearray()
    packet.extend(b&amp;quot;\x32&amp;quot;)  # Type of packet PUBLISH with QoS 1
    topic_length = len(topic).to_bytes(2, &amp;quot;big&amp;quot;)
    packet_id = (1).to_bytes(2, &amp;quot;big&amp;quot;)  # Packet identifyer
    payload = topic_length + topic.encode() + packet_id + message.encode()
    remaining_length = encode_remaining_length(len(payload))
    packet.extend(remaining_length)
    packet.extend(payload)
    return packet

# Funtion to build DISCONNECT packet
def create_disconnect_packet():
    return b&amp;quot;\xe0\x00&amp;quot;  # Type of packet DISCONNECT

def main():
    counter = 0
    while True:
        try:
            logging.debug(&amp;quot;Tentando conectar ao broker via SSL/TLS...&amp;quot;)
            with socket.create_connection((BROKER, PORT)) as sock:
                with ssl.create_default_context().wrap_socket(sock, server_hostname=BROKER) as mqtt_socket:
                    logging.debug(&amp;quot;Conex&amp;#227;o segura estabelecida com o broker MQTT&amp;quot;)
                    
                    # Send packet CONNECT with autentica&amp;#231;&amp;#227;o
                    connect_packet = create_connect_packet(CLIENT_ID, USERNAME, PASSWORD)
                    mqtt_socket.send(connect_packet)
                    logging.debug(&amp;quot;Pacote CONNECT enviado com autentica&amp;#231;&amp;#227;o&amp;quot;)
                    
                    # Create message with counter
                    counter += 1
                    message = MESSAGE_TEMPLATE.format(counter)
                    
                    # Send PUBLISH with QoS 1
                    publish_packet = create_publish_packet(TOPIC, message)
                    mqtt_socket.send(publish_packet)
                    logging.debug(f&amp;quot;Mensagem enviada: {message}&amp;quot;)
                    
                    # Wait delivery confirmation (PUBACK)
                    puback = mqtt_socket.recv(4)
                    if puback and puback[0] == 0x40:
                        logging.debug(f&amp;quot;PUBACK recebido para a mensagem {counter}&amp;quot;)
                    else:
                        logging.error(f&amp;quot;ERRO - Falha no recebimento do PUBACK para a mensagem {counter}&amp;quot;)
                    
                    time.sleep(0.5)
                    # Send DISCONNECT
                    disconnect_packet = create_disconnect_packet()
                    mqtt_socket.send(disconnect_packet)
                    logging.debug(&amp;quot;Desconectado do broker MQTT&amp;quot;)
                    
            time.sleep(0.1)  
        
        except Exception as e:
            logging.error(f&amp;quot;ERRO - Exce&amp;#231;&amp;#227;o inesperada: {e}&amp;quot;)
            time.sleep(0.1)  

if __name__ == &amp;quot;__main__&amp;quot;:
    main()
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So, is it for now.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Felipe&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems to use MQTT with RabbitMQ broker</title><link>https://devzone.nordicsemi.com/thread/522658?ContentTypeID=1</link><pubDate>Wed, 12 Feb 2025 13:38:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07e7d0e5-ccd0-43ee-8d7a-07ae32626ade</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Is your issue similar to what was discussed&amp;nbsp;&lt;a href="https://rabbitmq-users.narkive.com/V1Q1TXo8/increasing-the-handshake-timeout"&gt;here&lt;/a&gt;?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Have you considered reaching out to&amp;nbsp;&lt;a href="https://discord.com/invite/VwWnkG3GWy"&gt;RabbitMQ Community&lt;/a&gt;&amp;nbsp;on Discord?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>