mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-22 02:32:02 -08:00
Fix crash on reconnects when server is down. Closes #163
This commit is contained in:
parent
8fede90b9e
commit
2e703472f1
@ -108,13 +108,24 @@ func (m *MMClient) Login() error {
|
|||||||
m.Client = model.NewClient(uriScheme + m.Credentials.Server)
|
m.Client = model.NewClient(uriScheme + m.Credentials.Server)
|
||||||
m.Client.HttpClient.Transport = &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}}
|
m.Client.HttpClient.Transport = &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}}
|
||||||
m.Client.HttpClient.Timeout = time.Second * 10
|
m.Client.HttpClient.Timeout = time.Second * 10
|
||||||
|
|
||||||
|
for {
|
||||||
|
d := b.Duration()
|
||||||
// bogus call to get the serverversion
|
// bogus call to get the serverversion
|
||||||
m.Client.GetClientProperties()
|
m.Client.GetClientProperties()
|
||||||
if firstConnection && !supportedVersion(m.Client.ServerVersion) {
|
if firstConnection && !supportedVersion(m.Client.ServerVersion) {
|
||||||
return fmt.Errorf("unsupported mattermost version: %s", m.Client.ServerVersion)
|
return fmt.Errorf("unsupported mattermost version: %s", m.Client.ServerVersion)
|
||||||
}
|
}
|
||||||
m.ServerVersion = m.Client.ServerVersion
|
m.ServerVersion = m.Client.ServerVersion
|
||||||
|
if m.ServerVersion == "" {
|
||||||
|
m.log.Debugf("Server not up yet, reconnecting in %s", d)
|
||||||
|
time.Sleep(d)
|
||||||
|
} else {
|
||||||
m.log.Infof("Found version %s", m.ServerVersion)
|
m.log.Infof("Found version %s", m.ServerVersion)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
b.Reset()
|
||||||
|
|
||||||
var myinfo *model.Result
|
var myinfo *model.Result
|
||||||
var appErr *model.AppError
|
var appErr *model.AppError
|
||||||
|
Loading…
Reference in New Issue
Block a user