{"id":10235,"date":"2019-05-19T13:30:42","date_gmt":"2019-05-19T11:30:42","guid":{"rendered":"https:\/\/pi3g.com\/?p=10235"},"modified":"2019-05-19T13:30:42","modified_gmt":"2019-05-19T11:30:42","slug":"envoy-not-connecting-to-vernemq-for-mqtt-over-websockets-error-code-503","status":"publish","type":"post","link":"https:\/\/pi3g.com\/de\/envoy-not-connecting-to-vernemq-for-mqtt-over-websockets-error-code-503\/","title":{"rendered":"envoy verbindet sich nicht mit VerneMQ f\u00fcr MQTT \u00fcber Websockets, Fehlercode 503"},"content":{"rendered":"<p> Some quick background information for anyone running into the same issues, and how to debug them.<\/p>\n<h1>Error code 503<\/h1>\n<p>This is the error code I am getting:<\/p>\n<p><a href=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/05\/image-15.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1077\" height=\"138\" title=\"image\" style=\"display: inline; background-image: none;\" alt=\"image\" src=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/05\/image_thumb-15.png\" border=\"0\"><\/a><\/p>\n<p>Error during WebSocket handshake: Unexpected response code: 503.<\/p>\n<h1>Set envoy logging to debug<\/h1>\n<p>Here\u2019s my docker-compose.yaml for envoy:<\/p>\n<blockquote>\n<p>version: &#8216;3.7&#8217;<\/p>\n<p>services:<br \/>&nbsp;&nbsp; envoy:<br \/>&nbsp;&nbsp;&nbsp;&nbsp; build:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; context: .\/<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dockerfile: Dockerfile<br \/>&nbsp;&nbsp;&nbsp;&nbsp; container_name: penvoyage-morpheus-envoy<br \/>&nbsp;&nbsp;&nbsp;&nbsp; ports:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211; &#8220;80:1080&#8221;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211; &#8220;443:1443&#8221;<br \/>&nbsp;&nbsp;&nbsp;&nbsp; volumes:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211; type: volume<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; source: penvoyage_volume<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; target: \/etc\/envoy<br \/>&nbsp;&nbsp;&nbsp;&nbsp; networks:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211; envoy_net<br \/>&nbsp;&nbsp;&nbsp;&nbsp; user: &#8220;2000:2000&#8221;<br \/>&nbsp;&nbsp;&nbsp;&nbsp; #user: &#8220;root:root&#8221;<br \/>&nbsp;&nbsp;&nbsp;&nbsp; restart: unless-stopped<br \/><strong>&nbsp;&nbsp;&nbsp;&nbsp; environment:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; loglevel: debug<\/strong><\/p>\n<p>volumes:<br \/>&nbsp;&nbsp; penvoyage_volume: <br \/>&nbsp;&nbsp;&nbsp;&nbsp; external:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name: penvoyage_volume<\/p>\n<p>networks:<br \/>&nbsp;&nbsp; envoy_net:<br \/>&nbsp;&nbsp;&nbsp;&nbsp; external:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name: my-bridge-network<\/p>\n<p><\/p>\n<\/blockquote>\n<h1>Show the VerneMQ listeners<\/h1>\n<p>on the VerneMQ container, show the listeners and the ip\u2019s:<\/p>\n<blockquote>\n<p>vmq-admin listener show<\/p>\n<p>ip \u20134 addr show<\/p>\n<\/blockquote>\n<p><a href=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/05\/image-16.png\"><img loading=\"lazy\" decoding=\"async\" width=\"795\" height=\"300\" title=\"image\" style=\"display: inline; background-image: none;\" alt=\"image\" src=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/05\/image_thumb-16.png\" border=\"0\"><\/a><\/p>\n<p>Notice how mqttws is bound to <strong><font style=\"background-color: rgb(255, 255, 0);\">172.21.0.2<\/font><\/strong> on port 8080.<\/p>\n<p>There are two IPs present in the system: <\/p>\n<ul>\n<li>172.21.0.2<\/li>\n<li>172.18.0.7<\/li>\n<\/ul>\n<p>this is due to the VerneMQ container being part of two internal docker networks. <\/p>\n<h1>Look at the envoy log output<\/h1>\n<p>Here are some excerpts to illustrate a websocket opening request from the MQTT client:<\/p>\n<p>penvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][http] [source\/common\/http\/conn_manager_impl.cc:210] [C85] <b>new stream<\/b><\/p>\n<p>penvoyage-morpheus-envoy | &#8216;:authority&#8217;, &#8216;picockpit.local&#8217;<\/p>\n<p>penvoyage-morpheus-envoy | &#8216;:path&#8217;, &#8216;\/mqtt&#8217;<\/p>\n<p>penvoyage-morpheus-envoy | &#8216;:method&#8217;, &#8216;GET&#8217;<\/p>\n<p>penvoyage-morpheus-envoy | &#8216;connection&#8217;, &#8216;Upgrade&#8217;<\/p>\n<p><b>[C85][S10028475751570510266] cluster &#8216;target_verne&#8217; match for URL &#8216;\/mqtt&#8217;<\/b><\/p>\n<p>[C85][S10028475751570510266] router decoding headers:<\/p>\n<p><b><u>penvoyage-morpheus-envoy | &#8216;:authority&#8217;, &#8216;picockpit.local&#8217;<\/u><\/b><\/p>\n<p>penvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][pool] [source\/common\/http\/http1\/conn_pool.cc:82] creating a new connection<\/p>\n<p>penvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][client] [source\/common\/http\/codec_client.cc:26] [C86] connecting<\/p>\n<p>penvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][connection] [source\/common\/network\/connection_impl.cc:638] [C86] <b><font style=\"background-color: rgb(255, 255, 0);\">connecting to 172.18.0.7:8080<\/font><\/b><\/p>\n<p>penvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][connection] [source\/common\/network\/connection_impl.cc:647] [C86] <b>connection in progress<\/b><\/p>\n<p>penvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][pool] [source\/common\/http\/conn_pool_base.cc:20] <b><font style=\"background-color: rgb(255, 255, 0);\">queueing request due to no available connections<\/font><\/b><\/p>\n<p>penvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][connection] [source\/common\/network\/connection_impl.cc:525] [C86] delayed connection error: 111<br \/>\npenvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][connection] [source\/common\/network\/connection_impl.cc:183] [C86] closing socket: 0<br \/>\npenvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][client] [source\/common\/http\/codec_client.cc:82] [C86] disconnect. resetting 0 pending requests<br \/>\npenvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][pool] [source\/common\/http\/http1\/conn_pool.cc:123] [C86] <strong>client disconnected<\/strong><br \/>\npenvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][router] [source\/common\/router\/router.cc:532] [C85][S10028475751570510266] upstream reset<\/p>\n<p>penvoyage-morpheus-envoy | [2019-05-19 11:14:33.024][22][debug][http] [source\/common\/http\/conn_manager_impl.cc:1234] [C85][S10028475751570510266] encoding headers via codec (end_stream=false):<br \/><strong><br \/>\npenvoyage-morpheus-envoy | &#8216;:status&#8217;, &#8216;503&#8217;<\/strong><\/p>\n<p><\/p>\n<h1>The reason for the 503 error<\/h1>\n<p>In this case the reason for the 503 error is that envoy is not able to reach VerneMQ on IP 172.18.0.7 port 8080 \u2013 VerneMQ is listening on the other IP!<\/p>\n<p>Therefore envoy returns 503, that the upstream server is not available \u2013 and that this condition might be fixed once the upstream server becomes available again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Einige kurze Hintergrundinformationen f\u00fcr alle, die auf dieselben Probleme sto\u00dfen, und wie man sie behebt. Fehlercode 503 Dies ist der Fehlercode, den ich erhalte: Fehler beim WebSocket-Handshake: Unerwarteter Antwortcode: 503. Set envoy logging to debug Hier ist meine docker-compose.yaml f\u00fcr envoy: version: '3.7' services: envoy: build: context: .\/ dockerfile: Dockerfile container_name:...<\/p>","protected":false},"author":830,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[402],"tags":[607,601,481,599,589,602],"class_list":["post-10235","post","type-post","status-publish","format-standard","hentry","category-development","tag-connection","tag-debugging","tag-envoy","tag-mqtt","tag-vernemq","tag-websockets"],"_links":{"self":[{"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/posts\/10235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/users\/830"}],"replies":[{"embeddable":true,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/comments?post=10235"}],"version-history":[{"count":1,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/posts\/10235\/revisions"}],"predecessor-version":[{"id":10236,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/posts\/10235\/revisions\/10236"}],"wp:attachment":[{"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/media?parent=10235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/categories?post=10235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/tags?post=10235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}