tracing.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.17"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>Paho MQTT C Client Library: Tracing</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  13. <script type="text/javascript" src="search/searchdata.js"></script>
  14. <script type="text/javascript" src="search/search.js"></script>
  15. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  19. <div id="titlearea">
  20. <table cellspacing="0" cellpadding="0">
  21. <tbody>
  22. <tr style="height: 56px;">
  23. <td id="projectlogo"><img alt="Logo" src="pahologo.png"/></td>
  24. <td id="projectalign" style="padding-left: 0.5em;">
  25. <div id="projectname">Paho MQTT C Client Library
  26. </div>
  27. </td>
  28. </tr>
  29. </tbody>
  30. </table>
  31. </div>
  32. <!-- end header part -->
  33. <!-- Generated by Doxygen 1.8.17 -->
  34. <script type="text/javascript">
  35. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  36. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  37. /* @license-end */
  38. </script>
  39. <script type="text/javascript" src="menudata.js"></script>
  40. <script type="text/javascript" src="menu.js"></script>
  41. <script type="text/javascript">
  42. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  43. $(function() {
  44. initMenu('',true,false,'search.php','Search');
  45. $(document).ready(function() { init_search(); });
  46. });
  47. /* @license-end */</script>
  48. <div id="main-nav"></div>
  49. <!-- window showing the filter options -->
  50. <div id="MSearchSelectWindow"
  51. onmouseover="return searchBox.OnSearchSelectShow()"
  52. onmouseout="return searchBox.OnSearchSelectHide()"
  53. onkeydown="return searchBox.OnSearchSelectKey(event)">
  54. </div>
  55. <!-- iframe showing the search results (closed by default) -->
  56. <div id="MSearchResultsWindow">
  57. <iframe src="javascript:void(0)" frameborder="0"
  58. name="MSearchResults" id="MSearchResults">
  59. </iframe>
  60. </div>
  61. </div><!-- top -->
  62. <div class="PageDoc"><div class="header">
  63. <div class="headertitle">
  64. <div class="title">Tracing </div> </div>
  65. </div><!--header-->
  66. <div class="contents">
  67. <div class="textblock"><p>Runtime tracing is controlled by environment variables.</p>
  68. <p>Tracing is switched on by setting MQTT_C_CLIENT_TRACE. A value of ON, or stdout, prints to stdout, any other value is interpreted as a file name to use.</p>
  69. <p>The amount of trace detail is controlled with the MQTT_C_CLIENT_TRACE_LEVEL environment variable - valid values are ERROR, PROTOCOL, MINIMUM, MEDIUM and MAXIMUM (from least to most verbose).</p>
  70. <p>The variable MQTT_C_CLIENT_TRACE_MAX_LINES limits the number of lines of trace that are output to a file. Two files are used at most, when they are full, the last one is overwritten with the new trace entries. The default size is 1000 lines.</p>
  71. <h3>MQTT Packet Tracing</h3>
  72. <p>A feature that can be very useful is printing the MQTT packets that are sent and received. To achieve this, use the following environment variable settings: </p><div class="fragment"><div class="line">MQTT_C_CLIENT_TRACE=ON</div>
  73. <div class="line">MQTT_C_CLIENT_TRACE_LEVEL=PROTOCOL</div>
  74. </div><!-- fragment --><p> The output you should see looks like this: </p><div class="fragment"><div class="line">20130528 155936.813 3 stdout-subscriber -&gt; CONNECT cleansession: 1 (0)</div>
  75. <div class="line">20130528 155936.813 3 stdout-subscriber &lt;- CONNACK rc: 0</div>
  76. <div class="line">20130528 155936.813 3 stdout-subscriber -&gt; SUBSCRIBE msgid: 1 (0)</div>
  77. <div class="line">20130528 155936.813 3 stdout-subscriber &lt;- SUBACK msgid: 1</div>
  78. <div class="line">20130528 155941.818 3 stdout-subscriber -&gt; DISCONNECT (0)</div>
  79. </div><!-- fragment --><p> where the fields are:</p><ol type="1">
  80. <li>date</li>
  81. <li>time</li>
  82. <li>socket number</li>
  83. <li>client id</li>
  84. <li>direction (-&gt; from client to server, &lt;- from server to client)</li>
  85. <li>packet details</li>
  86. </ol>
  87. <h3>Default Level Tracing</h3>
  88. <p>This is an extract of a default level trace of a call to connect: </p><div class="fragment"><div class="line">19700101 010000.000 (1152206656) (0)&gt; <a class="code" href="_m_q_t_t_client_8h.html#aaa8ae61cd65c9dc0846df10122d7bd4e">MQTTClient_connect</a>:893</div>
  89. <div class="line">19700101 010000.000 (1152206656) (1)&gt; MQTTClient_connectURI:716</div>
  90. <div class="line">20130528 160447.479 Connecting to serverURI localhost:1883</div>
  91. <div class="line">20130528 160447.479 (1152206656) (2)&gt; MQTTProtocol_connect:98</div>
  92. <div class="line">20130528 160447.479 (1152206656) (3)&gt; MQTTProtocol_addressPort:48</div>
  93. <div class="line">20130528 160447.479 (1152206656) (3)&lt; MQTTProtocol_addressPort:73</div>
  94. <div class="line">20130528 160447.479 (1152206656) (3)&gt; Socket_new:599</div>
  95. <div class="line">20130528 160447.479 New socket 4 <span class="keywordflow">for</span> localhost, port 1883</div>
  96. <div class="line">20130528 160447.479 (1152206656) (4)&gt; Socket_addSocket:163</div>
  97. <div class="line">20130528 160447.479 (1152206656) (5)&gt; Socket_setnonblocking:73</div>
  98. <div class="line">20130528 160447.479 (1152206656) (5)&lt; Socket_setnonblocking:78 (0)</div>
  99. <div class="line">20130528 160447.479 (1152206656) (4)&lt; Socket_addSocket:176 (0)</div>
  100. <div class="line">20130528 160447.479 (1152206656) (4)&gt; Socket_error:95</div>
  101. <div class="line">20130528 160447.479 (1152206656) (4)&lt; Socket_error:104 (115)</div>
  102. <div class="line">20130528 160447.479 Connect pending</div>
  103. <div class="line">20130528 160447.479 (1152206656) (3)&lt; Socket_new:683 (115)</div>
  104. <div class="line">20130528 160447.479 (1152206656) (2)&lt; MQTTProtocol_connect:131 (115)</div>
  105. </div><!-- fragment --><p> where the fields are:</p><ol type="1">
  106. <li>date</li>
  107. <li>time</li>
  108. <li>thread id</li>
  109. <li>function nesting level</li>
  110. <li>function entry (&gt;) or exit (&lt;)</li>
  111. <li>function name : line of source code file</li>
  112. <li>return value (if there is one)</li>
  113. </ol>
  114. <h3>Memory Allocation Tracing</h3>
  115. <p>Setting the trace level to maximum causes memory allocations and frees to be traced along with the default trace entries, with messages like the following: </p><div class="fragment"><div class="line">20130528 161819.657 Allocating 16 bytes in heap at file /home/icraggs/workspaces/mqrtc/mqttv3c/src/MQTTPacket.c line 177 ptr 0x179f930</div>
  116. <div class="line"> </div>
  117. <div class="line">20130528 161819.657 Freeing 16 bytes in heap at file /home/icraggs/workspaces/mqrtc/mqttv3c/src/MQTTPacket.c line 201, heap use now 896 bytes</div>
  118. </div><!-- fragment --><p> When the last MQTT client object is destroyed, if the trace is being recorded and all memory allocated by the client library has not been freed, an error message will be written to the trace. This can help with fixing memory leaks. The message will look like this: </p><div class="fragment"><div class="line">20130528 163909.208 Some memory not freed at shutdown, possible memory leak</div>
  119. <div class="line">20130528 163909.208 Heap scan start, total 880 bytes</div>
  120. <div class="line">20130528 163909.208 Heap element size 32, line 354, file /home/icraggs/workspaces/mqrtc/mqttv3c/src/MQTTPacket.c, ptr 0x260cb00</div>
  121. <div class="line">20130528 163909.208 Content</div>
  122. <div class="line">20130528 163909.209 Heap scan end</div>
  123. </div><!-- fragment --> </div></div><!-- contents -->
  124. </div><!-- PageDoc -->
  125. <div class="ttc" id="a_m_q_t_t_client_8h_html_aaa8ae61cd65c9dc0846df10122d7bd4e"><div class="ttname"><a href="_m_q_t_t_client_8h.html#aaa8ae61cd65c9dc0846df10122d7bd4e">MQTTClient_connect</a></div><div class="ttdeci">int MQTTClient_connect(MQTTClient handle, MQTTClient_connectOptions *options)</div></div>
  126. <!-- start footer part -->
  127. <hr class="footer"/><address class="footer"><small>
  128. Generated on Thu Sep 29 2022 11:34:45 for Paho MQTT C Client Library by &#160;<a href="http://www.doxygen.org/index.html">
  129. <img class="footer" src="doxygen.png" alt="doxygen"/>
  130. </a> 1.8.17
  131. </small></address>
  132. </body>
  133. </html>