{"action":"created","issue":{"url":"https://api.github.com/repos/scrogson/romeo/issues/5","repository_url":"https://api.github.com/repos/scrogson/romeo","labels_url":"https://api.github.com/repos/scrogson/romeo/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/scrogson/romeo/issues/5/comments","events_url":"https://api.github.com/repos/scrogson/romeo/issues/5/events","html_url":"https://github.com/scrogson/romeo/pull/5","id":145655059,"number":5,"title":"mix: use upstream exml to resolve :badxml error","user":{"login":"dch","id":284368,"avatar_url":"https://avatars.githubusercontent.com/u/284368?v=3","gravatar_id":"","url":"https://api.github.com/users/dch","html_url":"https://github.com/dch","followers_url":"https://api.github.com/users/dch/followers","following_url":"https://api.github.com/users/dch/following{/other_user}","gists_url":"https://api.github.com/users/dch/gists{/gist_id}","starred_url":"https://api.github.com/users/dch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dch/subscriptions","organizations_url":"https://api.github.com/users/dch/orgs","repos_url":"https://api.github.com/users/dch/repos","events_url":"https://api.github.com/users/dch/events{/privacy}","received_events_url":"https://api.github.com/users/dch/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-04-04T11:20:19Z","updated_at":"2016-04-05T04:32:07Z","closed_at":"2016-04-05T04:30:21Z","pull_request":{"url":"https://api.github.com/repos/scrogson/romeo/pulls/5","html_url":"https://github.com/scrogson/romeo/pull/5","diff_url":"https://github.com/scrogson/romeo/pull/5.diff","patch_url":"https://github.com/scrogson/romeo/pull/5.patch"},"body":"Hey Sonny\r\n\r\nXMPP is new to me, and I avoid XML like the plague, so this is a short PR with a long story. If you can see what's wrong with the XML maybe we can get this addressed in https://github.com/esl/exml directly. \r\n\r\n## issue\r\n\r\nA new `hedwig_xmpp` or `hedwig_hipchat` app fails to connect to jabber or hipchat, due to failures in XML parsing early on. The upstream https://github.com/paulgray/exml dependency handles this correctly.\r\n\r\n## error as seen from hedwig_xmpp\r\n\r\n```elixir\r\n\r\n10:31:41.189 [error] GenServer #PID<0.219.0> terminating\r\n** (stop) {:badxml, {:xmlel, \"iq\", [{\"type\", \"set\"}, {\"id\", \"7a1c\"}], {:xmlel, \"bind\", [{\"xmlns\", \"urn:ietf:params:xml:ns:xmpp-bind\"}], [{:xmlel, \"resource\", [], {:xmlcdata, \"\"}}]}}, {:function_clause, [{:lists, :map, [#Function<1.76711811/1 in :exml.item_to_iolist/1>, {:xmlel, \"bind\", [{\"xmlns\", \"urn:ietf:params:xml:ns:xmpp-bind\"}], [{:xmlel, \"resource\", [], {:xmlcdata, \"\"}}]}], [file: 'lists.erl', line: 1237]}, {:exml, :item_to_iolist, 1, [file: 'src/exml.erl', line: 96]}, {:exml, :to_binary, 1, [file: 'src/exml.erl', line: 80]}, {Romeo.Transports.TCP, :send, 2, [file: 'lib/romeo/transports/tcp.ex', line: 178]}, {Romeo.Transports.TCP, :bind, 1, [file: 'lib/romeo/transports/tcp.ex', line: 113]}, {Romeo.Transports.TCP, :start_protocol, 1, [file: 'lib/romeo/transports/tcp.ex', line: 55]}, {Romeo.Connection, :connect, 2, [file: 'lib/romeo/connection.ex', line: 84]}, {Connection, :enter_connect, 5, [file: 'lib/connection.ex', line: 623]}]}}\r\n    (exml) src/exml.erl:81: :exml.to_binary/1\r\n    (romeo) lib/romeo/transports/tcp.ex:178: Romeo.Transports.TCP.send/2\r\n    (romeo) lib/romeo/transports/tcp.ex:113: Romeo.Transports.TCP.bind/1\r\n    (romeo) lib/romeo/transports/tcp.ex:55: Romeo.Transports.TCP.start_protocol/1\r\n    (romeo) lib/romeo/connection.ex:84: Romeo.Connection.connect/2\r\n    (connection) lib/connection.ex:623: Connection.enter_connect/5\r\n    (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3\r\nLast message: nil\r\nState: %Romeo.Connection{features: %Romeo.Connection.Features{amp?: false, compression?: false, mechanisms: [], registration?: false, stream_management?: false, tls?: false}, host: nil, jid: \"...@chat.hipchat.com\", nickname: \"alfred\", owner: #PID<0.218.0>, parser: nil, password: \"...\", port: nil, preferred_auth_mechanisms: [], require_tls: false, resource: \"\", rooms: [], socket: nil, socket_opts: [], ssl_opts: [], timeout: 5000, transport: Romeo.Transports.TCP}\r\n```\r\n\r\n## what was that stacktrace?\r\n\r\nI assume you've got https://github.com/ferd/recon in your ERL_LIBS already.\r\n\r\n```elixir\r\n\r\n$ iex --app recon -S mix\r\n\r\nieX()>  l(:exml)\r\nieX()>   :recon_trace.calls({:exml, :to_binary, :_} , 20, [{:pid, :all}, {:scope, :local}, :stack, :return])\r\n1\r\n\r\nieX()>  {:ok, pid} = Romeo.Connection.start_link([jid: \"...@..., password: \"...\", nickname: \"...\"])\r\n...\r\n```\r\n\r\n## invalid XML returned from Jabber & Hipchat\r\n\r\nUsing recon as above, the following traces that trigger `:badxml` are obtained just before the GenServer bites the dust. \r\n\r\n### ejabberd server\r\n\r\npaste into your erlang session:\r\n\r\n```erlang\r\nexml:to_binary({xmlel,<<\"iq\">>,\r\n       [{<<\"type\">>,<<\"set\">>},{<<\"id\">>,<<\"8e5c\">>}],\r\n       {xmlel,<<\"bind\">>,\r\n              [{<<\"xmlns\">>,<<\"urn:ietf:params:xml:ns:xmpp-bind\">>}],\r\n              [{xmlel,<<\"resource\">>,[],{xmlcdata,<<>>}}]}}).\r\n```\r\n\r\nresult:\r\n\r\n```erlang\r\n** exception error: {badxml,{xmlel,<<\"iq\">>,\r\n                                   [{<<\"type\">>,<<\"set\">>},{<<\"id\">>,<<\"8e5c\">>}],\r\n                                   {xmlel,<<\"bind\">>,\r\n                                          [{<<\"xmlns\">>,<<\"urn:ietf:params:xml:ns:xmpp-bind\">>}],\r\n                                          [{xmlel,<<\"resource\">>,[],{xmlcdata,<<>>}}]}},\r\n                            {function_clause,[{lists,map,\r\n                                                     [#Fun<exml.1.76711811>,\r\n                                                      {xmlel,<<\"bind\">>,\r\n                                                             [{<<\"xmlns\">>,<<\"urn:ietf:params:xml:ns:xmpp-bind\">>}],\r\n                                                             [{xmlel,<<\"resource\">>,[],{xmlcdata,<<>>}}]}],\r\n                                                     [{file,\"lists.erl\"},{line,1237}]},\r\n                                              {exml,item_to_iolist,1,[{file,\"src/exml.erl\"},{line,96}]},\r\n                                              {exml,to_binary,1,[{file,\"src/exml.erl\"},{line,80}]},\r\n                                              {erl_eval,do_apply,6,[{file,\"erl_eval.erl\"},{line,674}]},\r\n                                              {shell,exprs,7,[{file,\"shell.erl\"},{line,686}]},\r\n                                              {shell,eval_exprs,7,[{file,\"shell.erl\"},{line,641}]},\r\n                                              {shell,eval_loop,3,[{file,\"shell.erl\"},{line,626}]}]}}\r\n     in function  exml:to_binary/1 (src/exml.erl, line 81)\r\n```\r\n\r\n### hipchat XMPP\r\n\r\npaste into your erlang session:\r\n\r\n```erlang\r\nexml:to_binary({xmlel,<<\"iq\">>, \r\n       [{<<\"type\">>,<<\"set\">>},{<<\"id\">>,<<\"0356\">>}],\r\n       {xmlel,<<\"bind\">>,\r\n              [{<<\"xmlns\">>,<<\"urn:ietf:params:xml:ns:xmpp-bind\">>}],\r\n              [{xmlel,<<\"resource\">>,[],{xmlcdata,<<>>}}]}}).\r\n```\r\n\r\nresult:\r\n\r\n```erlang\r\n** exception error: {badxml,{xmlel,<<\"iq\">>,\r\n                                   [{<<\"type\">>,<<\"set\">>},{<<\"id\">>,<<\"0356\">>}],\r\n                                   {xmlel,<<\"bind\">>,\r\n                                          [{<<\"xmlns\">>,<<\"urn:ietf:params:xml:ns:xmpp-bind\">>}],\r\n                                          [{xmlel,<<\"resource\">>,[],{xmlcdata,<<>>}}]}},\r\n                            {function_clause,[{lists,map,\r\n                                                     [#Fun<exml.1.76711811>,\r\n                                                      {xmlel,<<\"bind\">>,\r\n                                                             [{<<\"xmlns\">>,<<\"urn:ietf:params:xml:ns:xmpp-bind\">>}],\r\n                                                             [{xmlel,<<\"resource\">>,[],{xmlcdata,<<>>}}]}],\r\n                                                     [{file,\"lists.erl\"},{line,1237}]},\r\n                                              {exml,item_to_iolist,1,[{file,\"src/exml.erl\"},{line,96}]},\r\n                                              {exml,to_binary,1,[{file,\"src/exml.erl\"},{line,80}]},\r\n                                              {erl_eval,do_apply,6,[{file,\"erl_eval.erl\"},{line,674}]},\r\n                                              {shell,exprs,7,[{file,\"shell.erl\"},{line,686}]},\r\n                                              {shell,eval_exprs,7,[{file,\"shell.erl\"},{line,641}]},\r\n                                              {shell,eval_loop,3,[{file,\"shell.erl\"},{line,626}]}]}}\r\n     in function  exml:to_binary/1 (src/exml.erl, line 81)\r\n```\r\n\r\n BTW I was unable to run romeo's test suite to check if switching repos broke other stuff.\r\n\r\n```elixir\r\nCompiled lib/romeo/transports/tcp.ex\r\nGenerated romeo app\r\nConsolidated JSX.Encoder\r\nConsolidated List.Chars\r\nConsolidated String.Chars\r\nConsolidated Collectable\r\nConsolidated Enumerable\r\nConsolidated IEx.Info\r\nConsolidated Inspect\r\nStarting ejabberd...\r\n\r\n13:07:03.292 [error] E(#PID<0.7526.0>::ejabberd_config:223) : Cannot load /Volumes/ramdisk/romeo/config/ejabberd.yml: no such file or directory\r\nCrash dump is being written to: /dev/null...[1]    17919 abort      mix test\r\n```"},"comment":{"url":"https://api.github.com/repos/scrogson/romeo/issues/comments/205639926","html_url":"https://github.com/scrogson/romeo/pull/5#issuecomment-205639926","issue_url":"https://api.github.com/repos/scrogson/romeo/issues/5","id":205639926,"user":{"login":"scrogson","id":53274,"avatar_url":"https://avatars.githubusercontent.com/u/53274?v=3","gravatar_id":"","url":"https://api.github.com/users/scrogson","html_url":"https://github.com/scrogson","followers_url":"https://api.github.com/users/scrogson/followers","following_url":"https://api.github.com/users/scrogson/following{/other_user}","gists_url":"https://api.github.com/users/scrogson/gists{/gist_id}","starred_url":"https://api.github.com/users/scrogson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrogson/subscriptions","organizations_url":"https://api.github.com/users/scrogson/orgs","repos_url":"https://api.github.com/users/scrogson/repos","events_url":"https://api.github.com/users/scrogson/events{/privacy}","received_events_url":"https://api.github.com/users/scrogson/received_events","type":"User","site_admin":false},"created_at":"2016-04-05T04:32:07Z","updated_at":"2016-04-05T04:32:07Z","body":"@dch decided to merge after all. This will at least update the `README` and give me time to complete the `fast_xml` conversion.\r\n\r\nThank you for this!"}}