{"action":"created","issue":{"url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/781","repository_url":"https://api.github.com/repos/xmppjs/xmpp.js","labels_url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/781/labels{/name}","comments_url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/781/comments","events_url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/781/events","html_url":"https://github.com/xmppjs/xmpp.js/issues/781","id":501903765,"node_id":"MDU6SXNzdWU1MDE5MDM3NjU=","number":781,"title":"Connection Opened Multiple Times","user":{"login":"ShadowRanger","id":5043545,"node_id":"MDQ6VXNlcjUwNDM1NDU=","avatar_url":"https://avatars3.githubusercontent.com/u/5043545?v=4","gravatar_id":"","url":"https://api.github.com/users/ShadowRanger","html_url":"https://github.com/ShadowRanger","followers_url":"https://api.github.com/users/ShadowRanger/followers","following_url":"https://api.github.com/users/ShadowRanger/following{/other_user}","gists_url":"https://api.github.com/users/ShadowRanger/gists{/gist_id}","starred_url":"https://api.github.com/users/ShadowRanger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShadowRanger/subscriptions","organizations_url":"https://api.github.com/users/ShadowRanger/orgs","repos_url":"https://api.github.com/users/ShadowRanger/repos","events_url":"https://api.github.com/users/ShadowRanger/events{/privacy}","received_events_url":"https://api.github.com/users/ShadowRanger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2019-10-03T07:40:54Z","updated_at":"2019-10-03T12:59:58Z","closed_at":null,"author_association":"NONE","body":"So I am having a potential issue where my XMPP client is opening the connection multiple times. I doubt this is intentional, so I thought it would be worth creating an issue about it to confirm. Here is my code:\r\n```\r\nconst username = \"secret\";\r\nconst password = \"secret\";\r\nconst client = client({\r\n\tservice: host,\r\n\tresource: \"origin\",\r\n\tusername: username,\r\n\tpassword: password\r\n});\r\nclient.on(\"status\", status => console.log(status));\r\nclient.on(\"error\", error => {\r\n\tif (error.condition === \"see-other-host\") {\r\n\t\tconst element = error.element.children[0];\r\n\t\tconst child = element.children[0];\r\n\r\n\t\tclient.options.service = `xmpp://${child}:5222`;\r\n\t\tclient.options.domain = \"chat.dm.origin.com\";\r\n\r\n\t\tconsole.log(\"error - reconnecting\");\r\n\t} else {\r\n\t\tconsole.log(error);\r\n\t}\r\n});\r\n\r\ntry {\r\n\tawait client.start();\r\n} catch (error) {\r\n\r\n}\r\n```\r\nThe console output I am receiving is the following:\r\n```\r\nconnecting\r\nconnect\r\nopening\r\nerror - reconnecting\r\nclosing\r\nclose\r\nopen\r\ndisconnecting\r\ndisconnect\r\nconnecting\r\nconnect\r\nopening\r\nopen\r\nopening\r\nopen\r\nopening\r\nopen\r\nonline\r\n```\r\nAs you can see, the connection is opened multiple times towards the end."},"comment":{"url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/comments/537934546","html_url":"https://github.com/xmppjs/xmpp.js/issues/781#issuecomment-537934546","issue_url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/781","id":537934546,"node_id":"MDEyOklzc3VlQ29tbWVudDUzNzkzNDU0Ng==","user":{"login":"ShadowRanger","id":5043545,"node_id":"MDQ6VXNlcjUwNDM1NDU=","avatar_url":"https://avatars3.githubusercontent.com/u/5043545?v=4","gravatar_id":"","url":"https://api.github.com/users/ShadowRanger","html_url":"https://github.com/ShadowRanger","followers_url":"https://api.github.com/users/ShadowRanger/followers","following_url":"https://api.github.com/users/ShadowRanger/following{/other_user}","gists_url":"https://api.github.com/users/ShadowRanger/gists{/gist_id}","starred_url":"https://api.github.com/users/ShadowRanger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShadowRanger/subscriptions","organizations_url":"https://api.github.com/users/ShadowRanger/orgs","repos_url":"https://api.github.com/users/ShadowRanger/repos","events_url":"https://api.github.com/users/ShadowRanger/events{/privacy}","received_events_url":"https://api.github.com/users/ShadowRanger/received_events","type":"User","site_admin":false},"created_at":"2019-10-03T12:59:58Z","updated_at":"2019-10-03T12:59:58Z","author_association":"NONE","body":"@sonnyp I have gone ahead and tried out the code you provided. I had to terminate the application early with your exact code as it was stuck in a reconnect loop because it wasn't handling the see-other-host error like I originally did. I have gotten 2 sets of logs, 1 with your code and one with yours but with the added see-other-host error handling.\r\n\r\n**Log 1 (No see-other-host error handling)**\r\nhttps://gist.github.com/ShadowRanger/8224b8d9ff7f33b6b92d88ece5378d99\r\n\r\n**Log 2 (Handling for see-other-host error)**\r\nhttps://gist.github.com/ShadowRanger/7564f40ff83001e54d4fa986860f4afd\r\n"}}
{"actor":{"display_login":"ShadowRanger"}}