acheong08 / EdgeGPT

Reverse engineered API of Microsoft's Bing Chat AI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: server rejected WebSocket connection: HTTP 200

jarhot1992 opened this issue · comments

commented

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

What happened?

program not working...

Steps to reproduce the problem

python3 -m EdgeGPT.EdgeGPT --cookie-file bing_cookies.json

What should have happened?

program working...

Version where the problem happens

0.12.1

What Python version are you running this with?

python 3.10

What is your operating system ?

No response

Command Line Arguments

python3 -m EdgeGPT.EdgeGPT --cookie-file bing_cookies.json

Console logs

Traceback (most recent call last):
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/websockets/legacy/client.py", line 662, in __await_impl__
    await protocol.handshake(
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/websockets/legacy/client.py", line 329, in handshake
    raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 200

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/websockets/legacy/client.py", line 655, in __await_impl_timeout__
    return await self.__await_impl__()
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/websockets/legacy/client.py", line 676, in __await_impl__
    await protocol.wait_closed()
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/miniconda3/envs/python3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/root/miniconda3/envs/python3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/EdgeGPT/EdgeGPT.py", line 235, in <module>
    main()
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/EdgeGPT/main.py", line 244, in main
    asyncio.run(async_main(args))
  File "/root/miniconda3/envs/python3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/root/miniconda3/envs/python3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/EdgeGPT/main.py", line 160, in async_main
    async for final, response in bot.ask_stream(
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/EdgeGPT/EdgeGPT.py", line 185, in ask_stream
    async for response in self.chat_hub.ask_stream(
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/EdgeGPT/chathub.py", line 102, in ask_stream
    async with connect(
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/websockets/legacy/client.py", line 637, in __aenter__
    return await self
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/websockets/legacy/client.py", line 654, in __await_impl_timeout__
    async with asyncio_timeout(self.open_timeout):
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/websockets/legacy/async_timeout.py", line 169, in __aexit__
    self._do_exit(exc_type)
  File "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/websockets/legacy/async_timeout.py", line 252, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

Additional information

No response

same problem

same to me when testing on the demo shown in the README (with little changes)

same to me, I had this running on my cloud

commented

same to me

same

same problem

same problem, already use proxy.

commented

Same for me on a server but it is working on my computer. On both, I use a proxy. So it's device related and not IP related I think.

who can find out the reason of this problem and solve it?

You can try to modify the file "/root/miniconda3/envs/python3.10/lib/python3.10/site-packages/websockets/legacy/client.py" line 442: open_timeout: Optional[float] = 30,#10 ping_interval: Optional[float] = 20,#20 ping_timeout: Optional[float] = 30,#20 to set them bigger.

Failed to connect to wss://sydney.bing.com/sydney/ChatHub: 200, message='Invalid response status', url=URL('wss://sydney.bing.com/sydney/ChatHub')

I managed to make it break on my local computer as well. I installed a VPN and set the location to Germany (the same region my Cloud is installed in). I'm getting the same error as you guys:

Connection to 'wss://sydney.bing.com/sydney/ChatHub' failed: Server sent invalid upgrade response: HTTP/1.1 200 OK X-Cache: CONFIG_NOCACHE nel: {"report_to":"network-errors","max_age":604800,"success_fraction":0.001,"failure_fraction":1.0} report-to: {"group":"network-errors","max_age":604800,"endpoints":[{"url":"https://aefd.nelreports.net/api/report?cat=sbc"}]} Accept-CH: Sec-CH-UA-Arch, Sec-CH-UA-Bitness, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version X-MSEdge-Ref: Ref A: DAF33563C6044741B9BFE3461935E159 Ref B: FRAEDGE1522 Ref C: 2023-07-13T16:58:11Z Date: Thu, 13 Jul 2023 16:58:11 GMT Content-Length: 0

I also noticed that the _U cookie is not present anymore when copying cookies. From what I understood, this cookie was required for authentication.

The error is from the PHP version of this script, but it's basically the same issue.

Failed to connect to wss://sydney.bing.com/sydney/ChatHub: 200, message='Invalid response status', url=URL('wss://sydney.bing.com/sydney/ChatHub')

same issue here

commented

Same issue to me.

commented

same

commented

Help, my bing-chan is not able to talk over 10mins!!

commented

Solution:16e00af

commented

Solution:16e00af

Works smoothly, cheers!!