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

panic: websocket not connected #548

Open
Ased2235 opened this issue Feb 18, 2024 · 0 comments
Open

panic: websocket not connected #548

Ased2235 opened this issue Feb 18, 2024 · 0 comments

Comments

@Ased2235
Copy link

Ased2235 commented Feb 18, 2024

Hello, i'm getting this error after i merge to latest ver of whatsmeow.

linkingCode, err := client.PairPhone("+"+number, true, whatsmeow.PairClientFirefox, "Firefox (Linux)")
   	if err != nil {
   		panic(err) // here's the error
   	}

and the old devices aren't connecting, it just hang at the start with no error.
here's my bot.go

	dbLog := waLog.Stdout("Database", "DEBUG", true)
	_, file, _, ok := runtime.Caller(0)
	if !ok {

		panic("Failed to get file name ")
	}

	name := strings.Split(file, "/")
	dbAddress := "file:qr/" + strings.Split(name[len(name)-1], ".")[0] + ".db?_foreign_keys=on"

	container, err := sqlstore.New(*dbDialect, dbAddress, dbLog)

	if err != nil {
		panic(err)
	}

	err = container.Upgrade()

	if err != nil {
		panic(err)
	} else {
		println("db upgraded to latest ver")
	}

	fmt.Println("starting")
	// If you want multiple sessions, remember their JIDs and use .GetDevice(jid) or .GetAllDevices() instead.
	deviceStore, err := container.GetFirstDevice()

	if err != nil {
		panic(err)
	}

	var v = [3]uint32{}

	v[0] = 2
	v[1] = 4
	v[2] = 1

	store.SetOSInfo("Chrome", v)

	client := whatsmeow.NewClient(deviceStore, nil) // waLog.Stdout("WA connection", "WARN", true))
	client.AddEventHandler(handler.HandlerInit)

	ch, err := client.GetQRChannel(context.Background())
	if err != nil {
		// This error means that we're already logged in, so ignore it.
		if !errors.Is(err, whatsmeow.ErrQRStoreContainsID) {
			fmt.Sprintf("Failed to get QR channel: %v", err)
		}
	} else {
		go func() {
			for evt := range ch {
				if evt.Event == "code" {
					qrterminal.GenerateHalfBlock(evt.Code, qrterminal.L, os.Stdout)
				} else {
					fmt.Sprintf("QR channel result: %s", evt.Event)
				}
			}
		}()
	}

	handler.SetCli(client, strings.Split(name[len(name)-1], ".")[0])

	// Listen to Ctrl+C (you can also do something else that prevents the program from exiting)
	c := make(chan os.Signal)
	signal.Notify(c, os.Interrupt, syscall.SIGTERM)
	<-c

	client.Disconnect()
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

1 participant