Skip to content
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

The login & error correction logic #39

Open
suntong opened this issue Dec 21, 2017 · 7 comments
Open

The login & error correction logic #39

suntong opened this issue Dec 21, 2017 · 7 comments

Comments

@suntong
Copy link

suntong commented Dec 21, 2017

Hi @songtianyi,

Please use this main.go to replace the one in my https://github.com/suntong/wx-go/tree/master/cmd/wx-go and see what you get.

I was trying to straight-out the login/re-login logic and work flow of wechat-go, and this is what i get when I tried to send "3824":

2017/12/20 19:31:32 [I] AcAIgEEJcA==
QRCode here
2017/12/20 19:32:01 [W] login response, window.code=408;
2017/12/20 19:32:01 [E] session exit, login response, window.code=408;
2017/12/20 19:32:30 [W] login response, window.code=201;
2017/12/20 19:32:45 [I] &{28490913... 
login successful on second attempt
...
2017/12/20 19:35:27 [I] webpush.web.wechat.com 0 2
2017/12/20 19:35:28 [W] no handlers for key [51]
2017/12/20 19:35:58 [I] webpush.web.wechat.com 0 0
2017/12/20 19:35:58 [E] Get https://webpush.web.wechat.com/cgi-bin/mmwebwx-bin/synccheck?_=1513816528000&deviceid=e219888375988845&r=1513816528000&sid=Blz45ePCcGpesIXo&skey=%40crypt_73c0b781_d641e4f28e65c0a46ca2be960effa5e3&synckey=1_667596270%7C2_667600694%7C3_667600570%7C11_667600646%7C13_667390534%7C201_1513816527%7C203_1513808070%7C1000_1513816443%7C1001_1513815314&uin=2849091348: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
2017/12/20 19:36:28 [I] webpush.web.wechat.com 0 0
2017/12/20 19:36:28 [E] Get https://webpush.web.wechat.com/cgi-bin/mmwebwx-bin/synccheck?_=1513816558000&deviceid=e219888375988845&r=1513816558000&sid=Blz45ePCcGpesIXo&skey=%40crypt_73c0b781_d641e4f28e65c0a46ca2be960effa5e3&synckey=1_667596270%7C2_667600694%7C3_667600570%7C11_667600646%7C13_667390534%7C201_1513816527%7C203_1513808070%7C1000_1513816443%7C1001_1513815314&uin=2849091348: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

The above error shows up right after I sent "3824", and they are the error I've been experiencing when it didn't work for me on my first try.

I don't think changing the external login logic should affect my plugin's internal behavior. So I need your help to figure out why it work and why it didn't. -- As I suspected in #34, I've always been scanning-in on the second attempt. I.e., after I saw the time out error in my console. whereas you must have been always scan-in right away. Could such minor difference make such huge impact?

Anyway, apparently the above main.go is not working for me. Could you see if you can make it work (for both first & second attempt) please?

Thanks

@suntong suntong changed the title The login flow The login & error correction logic Dec 21, 2017
@suntong
Copy link
Author

suntong commented Dec 21, 2017

Further on to the error correction logic, I reverted to my old main.go, and scanned in right away, and make my plugin working for me:

2017/12/20 19:38:42 [I] QYDQdzCioA==
QRCode here
2017/12/20 19:38:49 [W] login response, window.code=201;
2017/12/20 19:38:57 [I] &{2...
login successful on first attempt
...
2017/12/20 19:39:01 [I] entering synccheck loop
2017/12/20 19:39:02 [I] webpush.web.wechat.com 0 2
2017/12/20 19:39:03 [W] no handlers for key [51]
2017/12/20 19:39:03 [W] no handlers for key [51]
2017/12/20 19:39:09 [I] webpush.web.wechat.com 0 2
2017/12/20 19:39:10 [I] command '3824' received
2017/12/20 19:39:10 [I] game generated: 
 3 5
 8 6
-!!
:8 / (5 - 3) * 6

...
2017/12/20 19:39:11 [I] wechat message sent
2017/12/20 19:39:11 [I] gamer24 exit gracefully
2017/12/20 19:39:11 [I] webpush.web.wechat.com 0 2
2017/12/20 19:39:36 [I] webpush.web.wechat.com 0 2
2017/12/20 19:39:37 [I] command '3824' received
2017/12/20 19:39:37 [I] game generated: 
 9 8
 9 1
-XX
...

...
2017/12/20 20:11:10 [I] webpush.web.wechat.com 0 0
2017/12/20 20:11:40 [I] webpush.web.wechat.com 0 0
2017/12/20 20:11:40 [E] Get https://webpush.web.wechat.com/cgi-bin/mmwebwx-bin/synccheck?_=1513818670000&deviceid=e046698787456799&r=1513818670000&sid=zQZ88lAbDwKjxapB&skey=%40crypt_73c0b781_a68543a0c0a6d2f8d44e21e05ea20a4d&synckey=1_667596270%7C2_667600722%7C3_667600570%7C11_667600646%7C13_667390534%7C201_1513818591%7C203_1513808070%7C1000_1513816620%7C1001_1513816754&uin=2849091348: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
2017/12/20 20:12:10 [I] webpush.web.wechat.com 0 0
2017/12/20 20:12:10 [E] Get https://webpush.web.wechat.com/cgi-bin/mmwebwx-bin/synccheck?_=1513818700000&deviceid=e046698787456799&r=1513818700000&sid=zQZ88lAbDwKjxapB&skey=%40crypt_73c0b781_a68543a0c0a6d2f8d44e21e05ea20a4d&synckey=1_667596270%7C2_667600722%7C3_667600570%7C11_667600646%7C13_667390534%7C201_1513818591%7C203_1513808070%7C1000_1513816620%7C1001_1513816754&uin=2849091348: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

I.e., after letting the session running for ~30 minutes, I suddenly receiving the Timeout exceeded errors messages now. After that, the error will show up non-stop, until I killed it ~20 minutes later:

2017/12/20 20:28:40 [I] webpush.web.wechat.com 0 0
2017/12/20 20:28:40 [E] Get https://webpush.web.wechat.com/cgi-bin/mmwebwx-bin/synccheck?_=1513819690000&deviceid=e046698787456799&r=1513819690000&sid=zQZ88lAbDwKjxapB&skey=%40crypt_73c0b781_a68543a0c0a6d2f8d44e21e05ea20a4d&synckey=1_667596270%7C2_667600722%7C3_667600570%7C11_667600646%7C13_667390534%7C201_1513818591%7C203_1513808070%7C1000_1513816620%7C1001_1513816754&uin=2849091348: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
2017/12/20 20:29:10 [I] webpush.web.wechat.com 0 0
2017/12/20 20:29:10 [E] Get https://webpush.web.wechat.com/cgi-bin/mmwebwx-bin/synccheck?_=1513819720000&deviceid=e046698787456799&r=1513819720000&sid=zQZ88lAbDwKjxapB&skey=%40crypt_73c0b781_a68543a0c0a6d2f8d44e21e05ea20a4d&synckey=1_667596270%7C2_667600722%7C3_667600570%7C11_667600646%7C13_667390534%7C201_1513818591%7C203_1513808070%7C1000_1513816620%7C1001_1513816754&uin=2849091348: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
^C

After I received the error for the fist time, sending "3824" never works again, despite it has been working before in the same session.

This is another proof from a different angle showing that there is something wrong with the error recovery logic.

Please help, and, can you make sure the session can go on for hours and even days please? Thx.

@suntong
Copy link
Author

suntong commented Dec 21, 2017

Better yet,

please wrap up the first loop as internal loop so that session.LoginAndServe(false) will block and not return until logged in.

@songtianyi
Copy link
Owner

the session can go hours not days

@songtianyi
Copy link
Owner

songtianyi commented Dec 23, 2017

And the network may not stable.
You can add my wechat for quick response :)
id wxsongtianyi
Or join the wechat-go group, you can check the qrcode in wechat-go README

@suntong
Copy link
Author

suntong commented Dec 23, 2017

If by "network not stable" you meant the wechat server then I totally agree -- I had a unreliable network in China so I cannot tell, but here at home, I have fiber Internet, and the only thing I found unreliable is wechat server, not anything else. Moreover, trying from the hosting farms that have 99.9999% reliable rating gives me the exact same conclusion as well.

BTW, please elaborate what you mean by "the session can go hours not days". Thx.

@songtianyi
Copy link
Owner

songtianyi commented Dec 25, 2017

I didn't test the stability of wechat-go, as i know few hours later, the session will broken.

Get https://webpush.web.wechat.com/cgi-bin/mmwebwx-bi..

I have meet this error before, but rarely.

@suntong
Copy link
Author

suntong commented Dec 25, 2017

OK, when you have some time, please try out the two versions I gave/listed in my OP, and tell me how they work for you, how long can you have the session last, whether scanning-in on the first/second attempt make any differences to you, etc. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants