Rhymen / go-whatsapp

WhatsApp Web API
MIT License
2.09k stars 493 forks source link

error decoding login connResp: json: cannot unmarshal array into Go value of type map[string]interface {} #633

Open castillofranciscodaniel opened 3 years ago

castillofranciscodaniel commented 3 years ago

Hi! We were having a problem when the function Login() try to unmarshall the response from loginChan. Unmarshall is expecting a []map[string]interface{} but it is receiving a map[string]interface{}

`case r = <-loginChan: case <-time.After(wac.msgTimeout): return session, fmt.Errorf("login connection timed out") }

var resp map[string]interface{}
if err = json.Unmarshal([]byte(r), &resp); err != nil {
    return session, fmt.Errorf("error decoding login resp: %v\n", err)
}`

Log from server: goroutine 11 [running]: api-channel-whatsapp/pkg/messaging.login(0xc000198100, 0x1, 0x3) /go/src/app/pkg/messaging/whatsappImpl.go:553 +0x70e api-channel-whatsapp/pkg/messaging.WhatsappSession() /go/src/app/pkg/messaging/whatsappImpl.go:395 +0x1c2

fchattigo commented 3 years ago

I think, that is not the place where unmarshall can not work. I was looking and i think the problem is in Restore(), in some of the unmarshal

2021/11/03 17:05:38 [SUCCESS LOADIN CONFIG] 2021/11/03 17:05:39 [2 2121 6] 2021/11/03 17:05:39 [readSession][INIT] 2021/11/03 17:05:39 [DownloadSession][INIT] 2021/11/03 17:05:39 [DownloadSession][END] 2021/11/03 17:05:39 [readSession][END] 2021/11/03 17:05:39 [Login][ERROR] error decoding login connResp: json: cannot unmarshal array into Go value of type map[string]interface {} panic: error decoding login connResp: json: cannot unmarshal array into Go value of type map[string]interface {}

apariciojuan commented 3 years ago

Try this.

wac.SetClientVersion(3, 2123, 7)

manishswami commented 3 years ago

Working..

wac.SetClientVersion(2, 2142, 12)

fchattigo commented 3 years ago

Hi! thanks for answer me.Yes, it is working!

gurlivleenkainth2000 commented 2 years ago

Try this.

wac.SetClientVersion(3, 2123, 7)

Thank You, It is working for me