sigalor / whatsapp-web-reveng

Reverse engineering WhatsApp Web.
MIT License
6.13k stars 805 forks source link

Connection of backend to WhatsApp closed. Click to reconnect. #266

Open Brblol opened 4 years ago

Brblol commented 4 years ago

Hi

I ran npm install -f andpip install -r requirements.txt then npm start. Then I went to localhost:2018 and clicked the button a few times, when it gets to generating the QR code it says

Connection of backend to WhatsApp closed. Click to reconnect.

Any ideas whats gone wrong?

/whatsapp-web-reveng-master$ npm start

> whatsapp-web-reveng@1.0.0 start /home/a/Downloads/whatsapp-web-reveng-master
> npm run dev

> whatsapp-web-reveng@1.0.0 dev /home/a/Downloads/whatsapp-web-reveng-master
> concurrently --kill-others "./node_modules/.bin/nodemon index.js -i client -e js" "./node_modules/.bin/nodemon --exec python ./backend/whatsapp_web_backend.py -i client -e py" "sass --watch client/css/main.scss:client/css/main.css"

[0] [nodemon] 1.19.4
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching dir(s): *.*
[0] [nodemon] watching extensions: js
[0] [nodemon] starting `node index.js`
[1] [nodemon] 1.19.4
[1] [nodemon] to restart at any time, enter `rs`
[1] [nodemon] watching dir(s): *.*
[1] [nodemon] watching extensions: py
[1] [nodemon] starting `python ./backend/whatsapp_web_backend.py`
[2] Sass is watching for changes. Press Ctrl-C to stop.
[2] 
[0] whatsapp-web-reveng API server listening on port 2019
[0] whatsapp-web-reveng HTTP server listening on port 2018
[1] whatsapp-web-backend listening on port 2020
[0] got message  { command: 'api-connectBackend', from: 'client', type: 'call' }
[1] sending {"type": "connected", "from": "backend"}
[1] ('::ffff:127.0.0.1', 37622, 0, 0) connected to backend
[0] got message  { from: 'meta', type: 'opened' }
[0] got message  { type: 'connected', from: 'backend' }
[0] got message  { command: 'backend-connectWhatsApp',
[0]   from: 'client',
[0]   type: 'call' }
[1] 1585491565987,{"command":"backend-connectWhatsApp","from":"api2backend","type":"call"}
{u'from': u'api2backend', u'command': u'backend-connectWhatsApp', u'type': u'call'}
[1] --- request header ---
[1] GET /ws HTTP/1.1
[1] Upgrade: websocket
[1] Host: web.whatsapp.com
[1] Origin: http://web.whatsapp.com
[1] Sec-WebSocket-Key: AFLm2mBdAOv0mIXlrUxjfQ==
[1] Sec-WebSocket-Version: 13
[1] Connection: upgrade
[1] Origin: https://web.whatsapp.com
[1] 
[1] 
[1] -----------------------
[1] --- response header ---
[1] HTTP/1.1 101 Switching Protocols
[1] Date: Sun, 29 Mar 2020 14:19:26 GMT
[1] X-FB-TRIP-ID: 1679558926
[1] Upgrade: websocket
[1] Sec-WebSocket-Accept: q4btXGpu/lNdGx+0aMMwgg4zXQw=
[1] Connection: Upgrade
[1] -----------------------
[1] sending {"type": "resource_connected", "resource": "whatsapp", "resource_instance_id": "afadc1f8d54f490eaa6c69c29f5acebd", "from": "backend"}
[1] WhatsApp backend Websocket opened.
[0] got message  { type: 'resource_connected',
[0]   resource: 'whatsapp',
[0]   resource_instance_id: 'afadc1f8d54f490eaa6c69c29f5acebd',
[0]   from: 'backend' }
[0] got message  { command: 'backend-generateQRCode',
[0]   from: 'client',
[0]   type: 'call' }
[1] 1585491568234,{"command":"backend-generateQRCode","whatsapp_instance_id":"afadc1f8d54f490eaa6c69c29f5acebd","from":"api2backend","type":"call"}
{u'whatsapp_instance_id': u'afadc1f8d54f490eaa6c69c29f5acebd', u'type': u'call', u'command': u'backend-generateQRCode', u'from': u'api2backend'}
[1] send: '\x81\xfc\x04\xca\xd7\x865\xff\xef\xb30\xf3\xe6\xb32\xf2\xfb\xdd&\xab\xb3\xebm\xa4\xf5\xaa&\xa3\xb9\xefp\xe8\xfb\xdd4\xe6\xe4\xaa6\xf9\xee\xb6Y\xe6\x8c\xa4G\xa2\xa5\xe9i\xa3\xa2\xeb$\xab\xa3\xa66\xfa\xe5\xb6)\xfa\xe4\xab6\xf3\x83\xb71\xf0\xe6\xbf>\xf8\xef\xa86\xf9\xe1\xb37\xfe\xf5\xaa&\x89\xbf\xf4k\xa7\xbe\xf3i\xe8\x8a\xaa&\xba\x8f\xd5g\x80\xb2\xc1}\x81\xa6\xd0U\x9a\xe3\xc9Q\xbf\xef\xdc7\x8d\x86\xbb9\xe8\xfb\xf2v\xbf\xb2\xdb'
[1] Message after login:  1585491568,["Cmd",{"type":"update"}]
[1] Traceback (most recent call last):
[1]   File "/home/a/Downloads/whatsapp-web-reveng-master/backend/whatsapp.py", line 149, in onMessage
[1]     self.loginInfo["serverRef"] = json.loads(messageContent)["ref"];
[1] TypeError: list indices must be integers, not str
[1] 
[1] send: '\x88\x82\x1f\x8aA\xb5\x1cb'
[1] sending {"type": "resource_gone", "resource": "whatsapp", "resource_instance_id": "afadc1f8d54f490eaa6c69c29f5acebd", "from": "backend"}
[1] WhatsApp backend Websocket closed.
[0] got message  { type: 'resource_gone',
[0]   resource: 'whatsapp',
[0]   resource_instance_id: 'afadc1f8d54f490eaa6c69c29f5acebd',
[0]   from: 'backend' }
saxtorinc commented 4 years ago

i have the same problem the issue is whatsapp they have to modify their code to solve the issue

saxtorinc commented 4 years ago

[1] Message after login: 1585527026,["Cmd",{"type":"update"}] [1] Traceback (most recent call last): [1] File "/app/backend/whatsapp.py", line 149, in onMessage [1] self.loginInfo["serverRef"] = json.loads(messageContent)["ref"]; [1] TypeError: list indices must be integers, not str [1] [1] send: '\x88\x82\xb6\xb9a\xe5\xb5Q' [1] sending {"type": "resource_gone", "resource": "whatsapp", "resource_instance_id": "10a70c37576a412999bd9c5ca2325467", "from": "backend"} [1] WhatsApp backend Websocket closed. [0] got message { [0] type: 'resource_gone', [0] resource: 'whatsapp', [0] resource_instance_id: '10a70c37576a412999bd9c5ca2325467', [0] from: 'backend' [0] }

eduscrakozabrus commented 4 years ago

i have some issue. How to fix it?

gzsendiEhc commented 4 years ago

I found out that this problem might require proxy. WechatIMG24

gzsendiEhc commented 4 years ago

def connect(self): self.activeWs = websocket.WebSocketApp("wss://web.whatsapp.com/ws", on_message = lambda ws, message: self.onMessage(ws, message), on_error = lambda ws, error: self.onError(ws, error), on_open = lambda ws: self.onOpen(ws), on_close = lambda ws: self.onClose(ws), header = { "Origin: https://web.whatsapp.com" });

websocket.run_forever(http_proxy_host="127.0.0.1", http_proxy_port=1087);

    self.activeWs.run_forever(http_proxy_host="127.0.0.1", http_proxy_port=1087);
    self.websocketThread = Thread(target = self.activeWs.run_forever);
    self.websocketThread.daemon = True;
    self.websocketThread.start();