{"action":"created","issue":{"url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/588","repository_url":"https://api.github.com/repos/xmppjs/xmpp.js","labels_url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/588/labels{/name}","comments_url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/588/comments","events_url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/588/events","html_url":"https://github.com/xmppjs/xmpp.js/issues/588","id":378285289,"node_id":"MDU6SXNzdWUzNzgyODUyODk=","number":588,"title":"React Native: infinate loop when not-authorized","user":{"login":"DaveLombardo","id":39332586,"node_id":"MDQ6VXNlcjM5MzMyNTg2","avatar_url":"https://avatars0.githubusercontent.com/u/39332586?v=4","gravatar_id":"","url":"https://api.github.com/users/DaveLombardo","html_url":"https://github.com/DaveLombardo","followers_url":"https://api.github.com/users/DaveLombardo/followers","following_url":"https://api.github.com/users/DaveLombardo/following{/other_user}","gists_url":"https://api.github.com/users/DaveLombardo/gists{/gist_id}","starred_url":"https://api.github.com/users/DaveLombardo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaveLombardo/subscriptions","organizations_url":"https://api.github.com/users/DaveLombardo/orgs","repos_url":"https://api.github.com/users/DaveLombardo/repos","events_url":"https://api.github.com/users/DaveLombardo/events{/privacy}","received_events_url":"https://api.github.com/users/DaveLombardo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-11-07T13:22:56Z","updated_at":"2018-11-09T11:34:59Z","closed_at":null,"author_association":"NONE","body":"I use the latest xmppjs lib under React Native\r\n\r\nI implemented a custom auth function:\r\n```\r\n\r\nvar XMPP = require('@xmpp/client')\r\nvar xmppClient = XMPP.client({\r\n    service: Config.chatProtocol.websocket,\r\n    credentials: function authenticate(auth, mechanism) {\r\n        var crds = {\r\n            username: cbUserName,\r\n            password: cbUserPassword,\r\n        }\r\n        auth(crds)\r\n    }\r\n});\r\n\r\n...\r\n\r\nxmppClient.start();\r\n```\r\n\r\nNow I intentionally pass an invalid password for user and trying to connect.\r\n\r\n2 observations from here:\r\n1) I do not see a way on how to get a 'not-authorized' callback. Also, an 'error' callback never fires.\r\n2) In infinate loop occurs, so it's trying to authenticate again and again\r\nHere is log:\r\n```\r\n\r\n15:15:42: [Chat] SENT: <auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">ADM1NTY4My0xMgBuZXdVc2VyQXdlc29tZQ==</auth>\r\n15:15:42: [Chat] status opening \r\n15:15:42: [Chat] SENT: <open version=\"1.0\" xmlns=\"urn:ietf:params:xml:ns:xmpp-framing\" to=\"chat.connectycube.com\"/>\r\n15:15:42: [Chat] RECV: <failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"><not-authorized/></failure>\r\n15:15:42: [Chat] RECV: <open xmlns='urn:ietf:params:xml:ns:xmpp-framing' from='chat.connectycube.com' id='5cd49981-f8dd-40c1-b273-2b788864e4be' version='1.0' xml:lang='en' />\r\n15:15:42: [Chat] status open <open xmlns=\"urn:ietf:params:xml:ns:xmpp-framing\" from=\"chat.connectycube.com\" id=\"5cd49981-f8dd-40c1-b273-2b788864e4be\" version=\"1.0\" xml:lang=\"en\"/>\r\n15:15:42: [Chat] RECV: <stream:features xmlns:stream=\"http://etherx.jabber.org/streams\"><sm xmlns=\"urn:xmpp:sm:3\"/><mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>PLAIN_FAST</mechanism></mechanisms><ver xmlns=\"urn:xmpp:features:rosterver\"/><starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/><compression xmlns=\"http://jabber.org/features/compress\"><method>zlib</method></compression></stream:features>\r\n15:15:42: [Chat] SENT: <auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">ADM1NTY4My0xMgBuZXdVc2VyQXdlc29tZQ==</auth>\r\n15:15:42: [Chat] status opening \r\n15:15:42: [Chat] SENT: <open version=\"1.0\" xmlns=\"urn:ietf:params:xml:ns:xmpp-framing\" to=\"chat.connectycube.com\"/>\r\n15:15:43: [Chat] RECV: <failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"><not-authorized/></failure>\r\n15:15:43: [Chat] RECV: <open xmlns='urn:ietf:params:xml:ns:xmpp-framing' from='chat.connectycube.com' id='5cd49981-f8dd-40c1-b273-2b788864e4be' version='1.0' xml:lang='en' />\r\n15:15:43: [Chat] status open <open xmlns=\"urn:ietf:params:xml:ns:xmpp-framing\" from=\"chat.connectycube.com\" id=\"5cd49981-f8dd-40c1-b273-2b788864e4be\" version=\"1.0\" xml:lang=\"en\"/>\r\n15:15:43: [Chat] RECV: <stream:features xmlns:stream=\"http://etherx.jabber.org/streams\"><sm xmlns=\"urn:xmpp:sm:3\"/><mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>PLAIN_FAST</mechanism></mechanisms><ver xmlns=\"urn:xmpp:features:rosterver\"/><starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/><compression xmlns=\"http://jabber.org/features/compress\"><method>zlib</method></compression></stream:features>\r\n15:15:43: [Chat] SENT: <auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">ADM1NTY4My0xMgBuZXdVc2VyQXdlc29tZQ==</auth>\r\n15:15:43: [Chat] status opening \r\n15:15:43: [Chat] SENT: <open version=\"1.0\" xmlns=\"urn:ietf:params:xml:ns:xmpp-framing\" to=\"chat.connectycube.com\"/>\r\n15:15:43: [Chat] RECV: <failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"><not-authorized/></failure>\r\n15:15:43: [Chat] RECV: <open xmlns='urn:ietf:params:xml:ns:xmpp-framing' from='chat.connectycube.com' id='5cd49981-f8dd-40c1-b273-2b788864e4be' version='1.0' xml:lang='en' />\r\n15:15:43: [Chat] status open <open xmlns=\"urn:ietf:params:xml:ns:xmpp-framing\" from=\"chat.connectycube.com\" id=\"5cd49981-f8dd-40c1-b273-2b788864e4be\" version=\"1.0\" xml:lang=\"en\"/>\r\n15:15:43: [Chat] RECV: <stream:features xmlns:stream=\"http://etherx.jabber.org/streams\"><sm xmlns=\"urn:xmpp:sm:3\"/><mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>PLAIN_FAST</mechanism></mechanisms><ver xmlns=\"urn:xmpp:features:rosterver\"/><starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/><compression xmlns=\"http://jabber.org/features/compress\"><method>zlib</method></compression></stream:features>\r\n15:15:43: [Chat] SENT: <auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">ADM1NTY4My0xMgBuZXdVc2VyQXdlc29tZQ==</auth>\r\n15:15:43: [Chat] status opening \r\n15:15:43: [Chat] SENT: <open version=\"1.0\" xmlns=\"urn:ietf:params:xml:ns:xmpp-framing\" to=\"chat.connectycube.com\"/>\r\n```\r\n\r\nJust want to understand is it a bug or I missed something\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/comments/437334009","html_url":"https://github.com/xmppjs/xmpp.js/issues/588#issuecomment-437334009","issue_url":"https://api.github.com/repos/xmppjs/xmpp.js/issues/588","id":437334009,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzMzNDAwOQ==","user":{"login":"trampi","id":4292951,"node_id":"MDQ6VXNlcjQyOTI5NTE=","avatar_url":"https://avatars2.githubusercontent.com/u/4292951?v=4","gravatar_id":"","url":"https://api.github.com/users/trampi","html_url":"https://github.com/trampi","followers_url":"https://api.github.com/users/trampi/followers","following_url":"https://api.github.com/users/trampi/following{/other_user}","gists_url":"https://api.github.com/users/trampi/gists{/gist_id}","starred_url":"https://api.github.com/users/trampi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trampi/subscriptions","organizations_url":"https://api.github.com/users/trampi/orgs","repos_url":"https://api.github.com/users/trampi/repos","events_url":"https://api.github.com/users/trampi/events{/privacy}","received_events_url":"https://api.github.com/users/trampi/received_events","type":"User","site_admin":false},"created_at":"2018-11-09T11:34:59Z","updated_at":"2018-11-09T11:34:59Z","author_association":"NONE","body":"Could you try to change your code to the following?\r\n```\r\n    credentials: function authenticate(auth, mechanism) {\r\n        var crds = {\r\n            username: cbUserName,\r\n            password: cbUserPassword,\r\n        }\r\n        return auth(crds); // <--- added return, as auth returns a promise which you discard\r\n    }\r\n```\r\n\r\n"}}
{"actor":{"display_login":"trampi"}}