-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to NOT scan the QRCode on each opening #151
Comments
initial launch
bot stopped with ctrl-C restart bot and a QR is then again required.
|
Hi @dcsan , It seems that you are run into issue #31 According to your log: VERB PuppetWebBrowser open(https://wx.qq.com/zh_CN/htmledition/v2/images/webwxgeticon.jpg)
SILL PuppetWebBrowserCookie addCookies({"domain":".wechat.com","expiry":1482375002,"httpOnly":false,"name":"mm_lang","path":"/","secure":false,"value":"en_US"})
WARN PuppetWebBrowserCookie addCookies() exception: invalid cookie domain: invalid domain:".wechat.com"
(Session info: chrome=55.0.2883.95)
(Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.1 x86_64)
ERR PuppetWebBrowserCookie load() add() exception: invalid cookie domain: invalid domain:".wechat.com"
(Session info: chrome=55.0.2883.95)
(Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.1 x86_64)
VERB PuppetWebBrowser browser.loadSession(KBOT.wechaty.json) exception: invalid cookie domain: invalid domain:".wechat.com"
(Session info: chrome=55.0.2883.95)
(Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.1 x86_64)
VERB PuppetWebBrowser open(https://wx.qq.com) It's obviously that you are using I thought this problem was solved by this commit: c78329e#diff-67759812817c700bf8e67907e5adffa6R183 , but there must be something wrong with that: It should use the hostname from cookies to open url in browser, which should be I'll check it later, and you are welcome to review my code if you want to fix this faster. :) |
adding from chat please notice this two lines in the log:
We need to keep the domain in 1st line(wx.qq.com) and the 2st line(.wechat.com) the same. If it is not, you will have to re-scan BrowserCookie.hostname() should do that, but it's not. Code review is welcome at here: c78329e9dd1157e74614ae1d#diff-67759812817c700bf8e67907e5adffa6R183 |
when wechat sends me to web2.wechat.com the PROFILE.wechaty.json seems to have cookies at the right domain? [
{
"domain": ".wechat.com",
"expiry": 1482378174,
"httpOnly": false,
"name": "mm_lang",
"path": "/",
"secure": false,
"value": "en_US"
},
{
"domain": ".wechat.com",
"expiry": 1797694974,
"httpOnly": false,
"name": "webwx_auth_ticket",
"path": "/",
"secure": false,
"value": "CIsBEKi.......RiYc="
}, |
Yes, the cookie file should always right. What we need to do when starting Wechaty, is to get hostname out of cookie file, and use that hostname in the browser to visit the webwxapp. If so, the cookie can be set back correctly, and session can be restored. |
the cookie file still has .wechat domain?
|
Strange. The cookies should be saved to file right after user login, and will auto save to file every 5 minutes. If the hostname in cookie is not the same as the url, there must something wrong. |
hmm, deleted cookie file and now it seems to be updated to the right domain. maybe it's not getting overwritten properly somehow when the domain changes? btw the domains are there before I login.
after I login I assume the rest will appear. |
yes the domains change halfway the QR code is presented at this domain: but after I scan it I am redirected here: Could this maybe (possibly) be as I have an english OS? In any case the cookies file has the right (final) domain:
|
Could you please post the full file here, with two different version of I need them to write a unit test, thanks! |
initial state login is presented at wx.qq.com
|
after scanning the QRCode cookies file
|
If I quit and try to
|
FWIW I turned loglevel back to DEBUG and now I'm noticing a few of these:
|
@dcsan I just added some unit tests and a bug fix, could you have a try with the latest code? Please pay attention to this part of the log output: VERB PuppetWebBrowserCookie hostname()
VERB PuppetWebBrowserCookie getCookiesFromFile() from demo.wechaty.json
SILL PuppetWebBrowserCookie hostname() got web.wechat.com
VERB PuppetWebBrowser open(https://web.wechat.com/zh_CN/htmledition/v2/images/webwxgeticon.jpg)
SILL PuppetWebBrowserCookie addCookies({"domain":".wechat.com","expiry":1482380361,"httpOnly":false,"name":"mm_lang","path":"/","secure":false,"value":"en_US"}) This line: SILL PuppetWebBrowserCookie hostname() got web.wechat.com should match your cookie domain in cookie file. |
Still requires login each time but the cookies seem to match. QRCode is shown at web.wechat.com So up to here things match. However, it's still needed to scan the QRCode every time. After login we are redirected (now to web2.wechat.com - same domain but different subdomain) but this should be after login so not relevant. details:
Is it correct that I should stop the process with ctrl-C and then also "leave" the browser? |
|
Wechaty will create a new browser on each time it starts. So the old browser will be never reused. It seems When I use Wechaty on |
For what it's worth, I noticed that on one account I use the problems are much worse than another.
I can't think of any other differences. trying to track what might be the issue. |
Let's continue monitoring this problem. Also, there's #57 might related to this one. |
Did not hear from others about this issue. Close for now. |
Run
npm run doctor
orwechaty run doctor
(for docker user), paste output hereExpected behavior
I understand that giving a profile string will name the bot, and the cookie data will be saved, so I don't need to re-scan the QR code to login each time. ref:
https://github.com/wechaty/wechaty/wiki/API#wechatyinstanceprofilestring-wechaty
Actual behavior
Data IS saved to a file
Each time the bot starts up, it's needed to scan the QRCode again.
Steps to reproduce the behavior (and fixes, if any)
Launch a bot using any method. pass in:
the file
SOMENAME.wechat.json
IS created.I am using ctrl-C to kill the node process - is this correct?
I have tried leaving the browser open and closing it.
Paste the full output logs here with
WECHATY_LOG=silly
setnext comment
The text was updated successfully, but these errors were encountered: