# HG changeset patch # User Sascha L. Teichmann # Date 1559579075 -7200 # Node ID 317d176ef38c31b71d367f09aaceaa218181f084 # Parent 9114097964d719f3f846f154f40d59dbd1e42870 GM import: Try three times when timeouts happen on SOAP service. Increase SOAP timeout to 3 minutes. diff -r 9114097964d7 -r 317d176ef38c example_conf.toml --- a/example_conf.toml Mon Jun 03 18:07:57 2019 +0200 +++ b/example_conf.toml Mon Jun 03 18:24:35 2019 +0200 @@ -72,7 +72,7 @@ # ---------------------------------------------------------------------- # SOAP/XML-based importer setup: -# soap-timeout = "1m" +# soap-timeout = "3m" # Schema for "Testclient imports" # schema-dirs = "$PATH_TO_SCHEMATA" diff -r 9114097964d7 -r 317d176ef38c pkg/config/config.go --- a/pkg/config/config.go Mon Jun 03 18:07:57 2019 +0200 +++ b/pkg/config/config.go Mon Jun 03 18:24:35 2019 +0200 @@ -282,7 +282,7 @@ str("published-config", "", "path to a config file served to client.") - d("soap-timeout", time.Minute, "Timeout till a SOAP request is canceled.") + d("soap-timeout", 3*time.Minute, "Timeout till a SOAP request is canceled.") } var ( diff -r 9114097964d7 -r 317d176ef38c pkg/imports/gm.go --- a/pkg/imports/gm.go Mon Jun 03 18:07:57 2019 +0200 +++ b/pkg/imports/gm.go Mon Jun 03 18:24:35 2019 +0200 @@ -19,6 +19,7 @@ "context" "database/sql" "fmt" + "log" "sort" "strings" "time" @@ -177,9 +178,21 @@ Message_type: &mt, } + const maxTries = 3 + + tries := 0 + + again: resp, err := client.Get_messages(req) + if err != nil { - return nil, err + if t, ok := err.(interface{ Timeout() bool }); ok && t.Timeout() && tries < maxTries { + log.Println("warn: NtS SOAP request timed out. Trying again.") + tries++ + goto again + } + return nil, fmt.Errorf( + "Error requesting NtS service: %v", err) } result := resp.Result_message