Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 64e5a45cab0fc8db469e223eaefee8b99c1a722d Author: Wim <wim@42.be> Date: Mon May 08 20:44:36 2017 +0000 Fix crash on reconnects when server is down. Closes #163 diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index d234fb3..e579537 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -10813 +10824 @@ func (m *MMClient) Login() error {   m.Client = model.NewClient(uriScheme + m.Credentials.Server)   m.Client.HttpClient.Transport = &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}}   m.Client.HttpClient.Timeout = time.Second * 10 - // bogus call to get the serverversion - m.Client.GetClientProperties() - if firstConnection && !supportedVersion(m.Client.ServerVersion) { - return fmt.Errorf("unsupported mattermost version: %s", m.Client.ServerVersion) + + for { + d := b.Duration() + // bogus call to get the serverversion + m.Client.GetClientProperties() + if firstConnection && !supportedVersion(m.Client.ServerVersion) { + return fmt.Errorf("unsupported mattermost version: %s", 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) + break + }   } - m.ServerVersion = m.Client.ServerVersion - m.log.Infof("Found version %s", m.ServerVersion) + b.Reset()     var myinfo *model.Result   var appErr *model.AppError