3mora2 / WPP_Whatsapp

WPP_Whatsapp aim of exporting functions from WhatsApp Web to the python, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination
MIT License
57 stars 9 forks source link

playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded. #43

Closed xds-sdx closed 1 month ago

xds-sdx commented 2 months ago

Hey guys! How to solve this problem:playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.

3mora2 commented 2 months ago

Please write full error

xds-sdx commented 2 months ago
3mora2 commented 2 months ago

use

import logging

logger = logging.getLogger(name="WPP_Whatsapp")
logger.setLevel(logging.DEBUG)

and send all logs

xds-sdx commented 2 months ago

D:\pyobject\pythonProject.venv\Scripts\python.exe D:\pyobject\pythonProject\whatsapp\whatsapp.py 02-May-24 16:35:15 - INFO - test: Initializing... 02-May-24 16:35:15 - INFO - test: unregisterServiceWorker 02-May-24 16:35:15 - INFO - test: Setting WhatsApp WEB version to 2.2411.x 02-May-24 16:35:16 - ERROR - setWhatsappVersion Traceback (most recent call last): File "D:\pyobject\pythonProject.venv\Lib\site-packages\aiohttp\connector.py", line 1203, in _create_direct_connection hosts = await self._resolve_host(host, port, traces=traces) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pyobject\pythonProject.venv\Lib\site-packages\aiohttp\connector.py", line 880, in _resolve_host return await asyncio.shield(resolved_host_task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pyobject\pythonProject.venv\Lib\site-packages\aiohttp\connector.py", line 917, in _resolve_host_with_throttle addrs = await self._resolver.resolve(host, port, family=self._family) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pyobject\pythonProject.venv\Lib\site-packages\aiohttp\resolver.py", line 33, in resolve infos = await self._loop.getaddrinfo( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\python\Lib\asyncio\base_events.py", line 901, in getaddrinfo return await self.run_in_executor( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\python\Lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\python\Lib\socket.py", line 963, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ socket.gaierror: [Errno 11004] getaddrinfo failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "D:\pyobject\pythonProject.venv\Lib\site-packages\WPP_Whatsapp\api\layers\HostLayer.py", line 169, in setWhatsappVersion body = await getPageContent(version) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pyobject\pythonProject.venv\Lib\site-packages\WPP_Whatsapp\api\helpers\wa_version.py", line 43, in getPageContent async with session.get( File "D:\pyobject\pythonProject.venv\Lib\site-packages\aiohttp\client.py", line 1197, in aenter self._resp = await self._coro ^^^^^^^^^^^^^^^^ File "D:\pyobject\pythonProject.venv\Lib\site-packages\aiohttp\client.py", line 581, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pyobject\pythonProject.venv\Lib\site-packages\aiohttp\connector.py", line 544, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pyobject\pythonProject.venv\Lib\site-packages\aiohttp\connector.py", line 944, in _createconnection , proto = await self._create_direct_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pyobject\pythonProject.venv\Lib\site-packages\aiohttp\connector.py", line 1209, in _create_direct_connection raise ClientConnectorError(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host raw.githubusercontent.com:443 ssl:default [getaddrinfo failed] 02-May-24 16:35:16 - ERROR - Version not available for 2.2411.x, using latest as fallback 02-May-24 16:35:16 - INFO - test: Loading WhatsApp WEB 02-May-24 16:35:21 - INFO - test: Page loaded 02-May-24 16:35:21 - INFO - test: Injecting wapi.js 02-May-24 16:35:21 - INFO - test: Start WPPConfig 02-May-24 16:35:21 - INFO - test: WhatsApp WEB loaded 02-May-24 16:35:21 - INFO - test: WPPConfig 02-May-24 16:35:21 - DEBUG - test: start inject 02-May-24 16:35:21 - INFO - test: setInterval__checkStart 02-May-24 16:35:21 - DEBUG - test: Registering onStateChange event 02-May-24 16:35:21 - INFO - test: http => Waiting page load 02-May-24 16:35:21 - INFO - test: injected state: False 02-May-24 16:35:21 - INFO - test: wait for load webpackChunkwhatsapp_web_client 02-May-24 16:35:31 - INFO - test: inject wppconnect-wa.js 02-May-24 16:35:34 - INFO - test: inject wapi.js 02-May-24 16:35:34 - INFO - test: wait window.WPP.isReady 02-May-24 16:35:36 - INFO - test: wapi.js injected 02-May-24 16:35:37 - INFO - test: WhatsApp WEB version: 2.3000.1013214982 02-May-24 16:35:37 - INFO - test: WA-JS version: 3.2.3-alpha.0 02-May-24 16:35:37 - INFO - test: http => Checking is logged... 02-May-24 16:35:37 - DEBUG - test: http => authenticated=False 02-May-24 16:35:37 - INFO - test: Auto close configured to 60s 02-May-24 16:35:37 - INFO - test: http => Waiting for QRCode Scan... 02-May-24 16:35:37 - INFO - test: Waiting for QRCode Scan: Attempt 1 02-May-24 16:35:37 - DEBUG - test: Exposing onMessage function 02-May-24 16:35:37 - DEBUG - test: Exposing onAnyMessage function 02-May-24 16:35:37 - DEBUG - test: Exposing onAck function 02-May-24 16:35:37 - DEBUG - test: Exposing onNotificationMessage function 02-May-24 16:35:37 - DEBUG - test: Exposing onParticipantsChanged function 02-May-24 16:35:37 - DEBUG - test: Exposing onStateChange function 02-May-24 16:35:37 - DEBUG - test: Exposing onStreamChange function 02-May-24 16:35:37 - DEBUG - test: Exposing onIncomingCall function 02-May-24 16:35:37 - DEBUG - test: Exposing onInterfaceChange function 02-May-24 16:35:37 - DEBUG - test: Exposing onPresenceChanged function 02-May-24 16:35:37 - DEBUG - test: Exposing onLiveLocation function 02-May-24 16:35:37 - DEBUG - test: Exposing onAddedToGroup function 02-May-24 16:35:37 - DEBUG - test: Exposing onRevokedMessage function 02-May-24 16:35:37 - DEBUG - test: Exposing onReactionMessage function 02-May-24 16:35:37 - DEBUG - test: Exposing onPollResponse function 02-May-24 16:35:37 - DEBUG - test: Emitting onStateChange event (1 registered) 02-May-24 16:35:53 - INFO - test: http => Checking QRCode status... 02-May-24 16:35:53 - INFO - test: QRCode Success 02-May-24 16:35:53 - DEBUG - test: clearInterval <asyncio.locks.Event object at 0x00000261650B7DA0 [unset]> 02-May-24 16:35:53 - INFO - test: http => Checking phone is connected... 02-May-24 16:35:53 - DEBUG - test: Emitting onStateChange event (1 registered) 02-May-24 16:35:55 - DEBUG - test: Emitting onStateChange event (1 registered) 02-May-24 16:35:55 - DEBUG - test: Emitting onStateChange event (1 registered) 02-May-24 16:35:55 - INFO - Ready .... 02-May-24 16:35:58 - INFO - test: http => Connected 02-May-24 16:35:58 - DEBUG - test: clearInterval <asyncio.locks.Event object at 0x00000261650B7DA0 [set]> 02-May-24 16:36:00 - DEBUG - test: Send Message send_result={'id': 'true_201016708170@c.us_3EB0ED47F419B672E2BA25', 'ack': 1, 'sendMsgResult': {}}

Process finished with exit code 0

3mora2 commented 2 months ago

No playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded. in Log try agin

xds-sdx commented 2 months ago

Yes now there is no such error as mentioned above but the web page automatically closed before it did not appear this is a new problem

3mora2 commented 2 months ago

https://github.com/3mora2/WPP_Whatsapp/issues/41#issuecomment-2034606339

xds-sdx commented 2 months ago

How can I set the old version to use

3mora2 commented 2 months ago

https://github.com/3mora2/WPP_Whatsapp/blob/main/examples/wa_version.py

xds-sdx commented 2 months ago

Code: from WPP_Whatsapp import Create

start client with your session name

your_session_name = "test" creator = Create(session=your_session_name,version='2.3000.1') client = creator.start()

Now scan Whatsapp Qrcode in browser

check state of login

if creator.state != 'CONNECTED': raise Exception(creator.state)

phone_number = "201016708170" # or "+201016708170" message = "hello from wpp"

Simple message

result = client.sendText(phone_number, message)

D:\pyobject.venv\Scripts\python.exe D:\pyobject\whatsapp\whatsapp.py 04-May-24 12:39:48 - ERROR - setWhatsappVersion Traceback (most recent call last): File "D:\pyobject.venv\Lib\site-packages\WPP_Whatsapp\api\layers\HostLayer.py", line 169, in setWhatsappVersion body = await getPageContent(version) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pyobject.venv\Lib\site-packages\WPP_Whatsapp\api\helpers\wa_version.py", line 41, in getPageContent raise ValueError(f"Version not available for {versionMatch}") ValueError: Version not available for 2.3000.1 04-May-24 12:39:48 - ERROR - Version not available for 2.3000.1, using latest as fallback

Process finished with exit code 0

3mora2 commented 2 months ago

try open https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.3000.1013280057-alpha.html it open correct?

3mora2 commented 2 months ago

i removed use custom version by default, now use last version and no more timeout error

xds-sdx commented 2 months ago

Thank you. Problem solved. It would be better if the web page did not automatically close after the execution of the program

3mora2 commented 1 month ago

receive_message

creator.loop.run_forever()