Rhymen / go-whatsapp

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

Implementation Example in REST #110

Closed dimaskiddo closed 5 years ago

dimaskiddo commented 5 years ago

Following repository has an implementation of go-whatsapp in REST dimaskiddo/go-whatsapp-rest https://github.com/dimaskiddo/go-whatsapp-rest

Still Need Some Review Thanks

ghost commented 5 years ago

Hi Dimas, congratulations for the job.

We are facing a issue. About 2 min after scanning the qrcode and sending msg, the socket is closed. (error writing to socket: write tcp 172.17.0.2:45700->31.13.71.49:443: write: connection reset by peer). Any idea why this is happening?

dimaskiddo commented 5 years ago

yes i see the issue also, i think it's come from the websocket connection got interupted when the error show, you can't re-use the connection (and may be also due to the gorilla websocket), need some modification in Go WhatsApp Library it self

My idea currently always open new connection then login or restore session for new event (like send text message), after that close the web socket connection (this function still not available)

What i need from the Go WhatsApp is a public function to close the connection, may be like this:

func (wac *Conn) Close() { wac.wsConn.Close() }

Still need some test

ghost commented 5 years ago

I understand, but I would like keep alive the connection for receiving the messages. Is it a problem with the Go WhatsApp or gorilla websocket Library?

dimaskiddo commented 5 years ago

What i know Go WhatsApp already make a keep alived routine with interval between 20 - 90 seconds, i think the problem was related to this issues #74 and issues #106, so when connection dropped out we can't even to restore the session

Will try some sollution in issues #106 by modifying the keep alived interval

dimaskiddo commented 5 years ago

screen shot 2019-03-02 at 12 42 03 am

Test result after modifying some section in conn.go [dimaskiddo/go-whatsapp] like servers, keep alived, close and reconnect, the websocket was keep alived for near of 1 hours

Still need more test

ghost commented 5 years ago

You're right. I got the same result. Thanks.

dimaskiddo commented 5 years ago

Clossing my own issue due to not related with go-whatsapp package, sorry :)

victormedranop commented 5 years ago

dimaskiddo how you solve this? when i try to send a message disconnect the wac. i need to restart de solution.

Victor

dimaskiddo commented 5 years ago

as i know you can use error handler to do reconnection or restoring session, since the readPump already rewrited.

For this issue (sudden closed conenction) i just do some tweak and changes, as i prefer to use