Skip to content

GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.

feat: add auto reconnect (#30)

Aldino Kemalcbf9e76f7ba0
diff --git a/src/cmd/root.go b/src/cmd/root.go
index 7764bc46..cbef10a6 100644
--- a/src/cmd/root.go
+++ b/src/cmd/root.go
@@ -17,8 +17,10 @@ import (
"github.com/markbates/pkger"
_ "github.com/mattn/go-sqlite3"
"log"
+ "net/http"
"os"
"strings"
+ "time"
"github.com/spf13/cobra"
)
@@ -108,6 +110,11 @@ func runRest(cmd *cobra.Command, args []string) {
})
})
+ // Set auto reconnect to whatsapp server after booting
+ go func() {
+ time.Sleep(2 * time.Second)
+ _, _ = http.Get(fmt.Sprintf("http://localhost:%s/app/reconnect", config.AppPort))
+ }()
err = app.Listen(":" + config.AppPort)
if err != nil {
log.Fatalln("Failed to start: ", err.Error())