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

Error: Unexpected server response: 502 #202

Closed
hoonlight opened this issue Mar 17, 2023 · 5 comments · Fixed by #204
Closed

Error: Unexpected server response: 502 #202

hoonlight opened this issue Mar 17, 2023 · 5 comments · Fixed by #204

Comments

@hoonlight
Copy link

hoonlight commented Mar 17, 2023

  • I am using bing jailbreak mode (Sydney) and stream=true.
  • For the node-chatgpt-api version, I am using the latest version by git clone.
  • I am running an api server using docker.

The following problem occurs intermittently.

It works fine for a while, but suddenly an error occurs.
I've tested it several times, but I don't know under what circumstances it happens.

Error: Unexpected server response: 502
disconnected
    at ClientRequest.<anonymous> (/var/chatgpt-api/node_modules/ws/lib/websocket.js:888:7)
    at ClientRequest.emit (node:events:513:28)
    at HTTPParser.parserOnIncomingClient (node:_http_client:701:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
    at TLSSocket.socketOnData (node:_http_client:542:22)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)

My client side code is below. I'll add it in case it might be helpful.

async with aiohttp.ClientSession() as session:
        async with session.post(url, json=payload) as resp:
            if resp.status == 200:
                async for line in resp.content:
                    ......

If this is a microsoft server side problem, I would appreciate it if you could throw an exception on this. Right now handling the exception on the client doesn't solve the problem until I restart the api server.

@hoonlight
Copy link
Author

hoonlight commented Mar 17, 2023

Also, the error below also occurs occasionally.

Error: InternalError: Unhandled Exception
    at WebSocket.<anonymous> (file:///var/chatgpt-api/src/BingAIClient.js:383:36)
    at WebSocket.emit (node:events:525:35)
    at Receiver.receiverOnMessage (/var/chatgpt-api/node_modules/ws/lib/websocket.js:1184:20)
    at Receiver.emit (node:events:513:28)
    at Receiver.dataMessage (/var/chatgpt-api/node_modules/ws/lib/receiver.js:541:14)
    at Receiver.getData (/var/chatgpt-api/node_modules/ws/lib/receiver.js:459:17)
    at Receiver.startLoop (/var/chatgpt-api/node_modules/ws/lib/receiver.js:158:22)
    at Receiver._write (/var/chatgpt-api/node_modules/ws/lib/receiver.js:84:10)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)

@waylaidwanderer
Copy link
Owner

Error: InternalError: Unhandled Exception

This one is a problem on Bing's side and shouldn't cause any issues; just retry.

Error: Unexpected server response: 502

Don't think I've run into this one before. Can you run the API server with node --trace-warnings bin/server.js to try to log where it came from?

@tqnghia1998
Copy link

It happened to me too bro. The cause is error happened on websocket handshake

ws.on('error', console.error) // Should throw error here

That is for the error Error: Unexpected server response: 502

I am also facing [Error: The moderation filter triggered. Try again with different wording], it seems like Bing has patched the jailbreak method

@hoonlight
Copy link
Author

hoonlight commented Mar 17, 2023

Error: Unexpected server response: 502
    at ClientRequest.<anonymous> (/var/chatgpt-api/node_modules/ws/lib/websocket.js:888:7)
    at ClientRequest.emit (node:events:513:28)
    at HTTPParser.parserOnIncomingClient (node:_http_client:701:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
    at TLSSocket.socketOnData (node:_http_client:542:22)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)

Since the error reoccurred, my guess was completely wrong. I deleted my comment.

@dene-
Copy link
Contributor

dene- commented Mar 17, 2023

Yes, the jailbreak is "patched", but they also added a 2000 character limit. If you surpass it on your message you'll get an Hmm…let’s try a different topic. Sorry about that. What else is on your mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants