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

Program hangs when second session tries to start #23

Open
handlerug opened this issue Jan 27, 2019 · 6 comments
Open

Program hangs when second session tries to start #23

handlerug opened this issue Jan 27, 2019 · 6 comments

Comments

@handlerug
Copy link

I am trying to implement multi-account feature in my program. I define array of accounts and try to login:

// Account represents Telegram account.
type Account struct {
	Phone      string
	ConfigPath string
	// ...
}
accs := make(map[string]*Account)
accs[args[0]] = &Account{
	Phone:      args[0],
	ConfigPath: os.Args[1],
}
accs[args[0]].Login() // it works
accs[args[1]] = &Account{
	Phone:      args[1],
	ConfigPath: os.Args[1],
}
accs[args[1]].Login() // now it hangs

Logs:

... first account logs ...
... now second account tries to login
2019/01/27 23:42:54 [MM 290413704] start
2019/01/27 23:42:54 [MM 290413704] newsession to  149.154.167.50:443
here it hangs

Does your library support multiple sessions? I explored your code and I think those accounts should use different managers. If you need the Account.Login method's code, I can upload it as gist (this is the code from SimpleShell, with small changes). Thank you a lot for this beautiful library!

@altfoxie
Copy link

Ha-ha, classic.

@cjongseok
Copy link
Owner

@handlerug Multi-sessions are not supported in this library. I left a room for the multi-sessions in manager but it is not implemented yet. As you said multi-managers can work with multi-sessions, but I didn't try that.

@handlerug
Copy link
Author

handlerug commented Jan 28, 2019

Thank you for reply! I already use multiple managers for accounts, but as I described in the issue, this approach doesn't work for unknown reason :(

@handlerug
Copy link
Author

Also, I explored library code and found out that it hangs in manager.NewAuthentication(...) when it tries to get the response from Telegram server:

image

Maybe Telegram servers ignore this request, and Go http client just hangs (because it's without timeout by default)?

@cjongseok
Copy link
Owner

@handlerug When manager.NewAuthentication(...) is called, manager's event loop handles newsession event at this line. You can compare your auth progress with printed logs I think. I hope this can help you to make multi-sessions work.

Thanks for your participations for multi-session uses in various ways. If it finally work with multi managers, it would be cool. But if not, I think reserving it to the next version of the lib would be the better way. In the following major update, I will seriously consider it together with other feature requests.

@handlerug
Copy link
Author

Woah, a month has already passed since last reply to this issue. I tried looking at the code, and it hangs at newSession(...) if logs don't lie. I don't know why, so I forgot about this issue. Maybe there are conflicting connections (but Telegram clients support multi-accounts)?

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

3 participants