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

IPv6 not falling back to IPv4 (aiohttp upstream issue - No Happy Eyeballs support) #85

Open
Diend2023 opened this issue May 9, 2023 · 21 comments
Labels
help wanted Extra attention is needed

Comments

@Diend2023
Copy link

When I tried to run 'edge tts -- text' Hello, world '-- write media hello. mp3', this error occurred.
I believe this is my own reason, but I cannot solve it.

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1070, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1054, in create_connection
sock = await self._connect_sock(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 963, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect
return await fut
File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 541, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('2620:1ec:c11::237', 443, 0, 0)

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

Traceback (most recent call last):
File "/usr/local/bin/edge-tts", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/edge_tts/util.py", line 136, in main
loop.run_until_complete(_async_main())
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/usr/local/lib/python3.10/site-packages/edge_tts/util.py", line 129, in _async_main
await _run_tts(args)
File "/usr/local/lib/python3.10/site-packages/edge_tts/util.py", line 65, in _run_tts
async for chunk in tts.stream():
File "/usr/local/lib/python3.10/site-packages/edge_tts/communicate.py", line 305, in stream
async with aiohttp.ClientSession(
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in aenter
self._resp = await self._coro
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 779, in _ws_connect
resp = await self.request(
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request
conn = await self._connector.connect(
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 988, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host speech.platform.bing.com:443 ssl:default [Connect call failed ('2620:1ec:c11::237', 443, 0, 0)]

@rany2
Copy link
Owner

rany2 commented May 9, 2023

Are you connecting to a VPN with an "IPv6 killswitch"?

@Diend2023
Copy link
Author

I once failed to configure VPN, but then I turned off all agents in the environment variable. I am not sure if I have completely cancelled my configuration

@rany2
Copy link
Owner

rany2 commented May 9, 2023

This seems like an IPv6 configuration issue on your end.

@rany2
Copy link
Owner

rany2 commented May 9, 2023

Indeed, it seems aiohttp does not support Happy Eyeballs: aio-libs/aiohttp#4451

@Diend2023
Copy link
Author

So should I try to turn off ipv6?

@rany2
Copy link
Owner

rany2 commented May 9, 2023

Could you try that and let me know?

@Diend2023
Copy link
Author

yes,thank you for your help

@rany2
Copy link
Owner

rany2 commented May 9, 2023

Perfect, I will see if I could work around it. In the worst case I'll consider switching to another library.

@rany2 rany2 changed the title aiohttp.client_exceptions.ClientConnectorError IPv6 not falling back to IPv4 (aiohttp upstream issue - No Happy Eyeballs support) May 9, 2023
@Diend2023
Copy link
Author

This seems to be valid, but I have encountered a certificate issue again:

aiohttp.client_ exceptions.ClientConnectorCertificateError: Cannot connect to host speech.platform.bing.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]

@rany2
Copy link
Owner

rany2 commented May 9, 2023

@wanqifa Someone is hijacking your SSL connection, are you using this at a workplace? Edit, can you run this:

curl -4vvvv https://speech.platform.bing.com
curl -6vvvv https://speech.platform.bing.com

@Diend2023
Copy link
Author

The first one can run

@rany2
Copy link
Owner

rany2 commented May 9, 2023

@wanqifa I mean can you share the output?

@Diend2023
Copy link
Author

[root@localhost ~]# curl -4vvvv https://speech.platform.bing.com

  • About to connect() to speech.platform.bing.com port 443 (#0)
  • Trying 13.107.21.237...
  • Connected to speech.platform.bing.com (13.107.21.237) port 443 (#0)
  • Initializing NSS with certpath: sql:/etc/pki/nssdb
  • CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
  • SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
  • Server certificate:
  •   subject: CN=www.bing.com
    
  •   start date: Feb 16 03:47:45 2023 GMT
    
  •   expire date: Aug 16 03:47:45 2023 GMT
    
  •   common name: www.bing.com
    
  •   issuer: CN=Microsoft RSA TLS CA 02,O=Microsoft Corporation,C=US
    

GET / HTTP/1.1
User-Agent: curl/7.29.0
Host: speech.platform.bing.com
Accept: /

< HTTP/1.1 400 Bad Request
< Transfer-Encoding: chunked
< X-MSEdge-Ref: 0O2JaZAAAAADeWVAa6FhpQ4kUKczxXQDrU0cxRURHRTAzMjEARWRnZQ==
< Date: Tue, 09 May 2023 15:09:47 GMT
<

  • Connection #0 to host speech.platform.bing.com left intact

Our services aren't available right now

We're working to restore all services as soon as possible. Please check back soon.

0O2JaZAAAAADeWVAa6FhpQ4kUKczxXQDrU0cxRURHRTAzMjEARWRnZQ==

[root@localhost ~]# curl -6vvvv https://speech.platform.bing.com

  • About to connect() to speech.platform.bing.com port 443 (#0)
  • Trying 2620:1ec:c11::237...
  • Failed to connect to 2620:1ec:c11::237: Network is unreachable
  • couldn't connect to host at speech.platform.bing.com:443
  • Closing connection 0
    curl: (7) Failed to connect to 2620:1ec:c11::237: Network is unreachable

@rany2
Copy link
Owner

rany2 commented May 9, 2023

@wanqifa Thank you, my understanding is that the SSL error only happens sometimes; right?

@Diend2023
Copy link
Author

Diend2023 commented May 9, 2023

Since I started using edge-tts, this function has not been successful.
But I can use it on another device

@xiaoqiuyinhetaotao
Copy link

xiaoqiuyinhetaotao commented Jun 8, 2023

I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py

26 from aiohttp import TCPConnector

305 async with aiohttp.ClientSession(
306 trust_env=True,connector=TCPConnector(ssl=False)
307 )

@Diend2023
Copy link
Author

I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py

26 from aiohttp import TCPConnector

305 async with aiohttp.ClientSession( 306 trust_env=True,connector=TCPConnector(ssl=False) 307 )

I have tried this before, but it failed. I will try your method again

@Diend2023
Copy link
Author

I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py

26 from aiohttp import TCPConnector

305 async with aiohttp.ClientSession( 306 trust_env=True,connector=TCPConnector(ssl=False) 307 )

This is useful, thank you very much !!!!!!!!!!!!

@rany2
Copy link
Owner

rany2 commented Jun 8, 2023

I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py

26 from aiohttp import TCPConnector

305 async with aiohttp.ClientSession( 306 trust_env=True,connector=TCPConnector(ssl=False) 307 )

I'm going to implement this but why did you disable SSL verification?

@Diend2023
Copy link
Author

I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py

26 from aiohttp import TCPConnector
305 async with aiohttp.ClientSession( 306 trust_env=True,connector=TCPConnector(ssl=False) 307 )

I'm going to implement this but why did you disable SSL verification?

Perhaps the SSL certificate validation error was caused by invalid certificates in certain systems or Python versions. I have found similar issues in the issues section of aiohttp before.

@rany2
Copy link
Owner

rany2 commented Aug 12, 2023

I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py

26 from aiohttp import TCPConnector
305 async with aiohttp.ClientSession( 306 trust_env=True,connector=TCPConnector(ssl=False) 307 )

I'm going to implement this but why did you disable SSL verification?

Perhaps the SSL certificate validation error was caused by invalid certificates in certain systems or Python versions. I have found similar issues in the issues section of aiohttp before.

Should be resolved by 8f8a334

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants