terry3041 / pyChatGPT

An unofficial Python wrapper for OpenAI's ChatGPT API
GNU General Public License v3.0
1.35k stars 252 forks source link

Failed to establish a new connection #73

Open iaston opened 1 year ago

iaston commented 1 year ago

If error while running, I try to close GPT and then init one again. Sometime init will failed (the connection may be failed). (taskkill is used in the program to prevent the module failing to close the chrome window.)

image

image

terry3041 commented 1 year ago

In your line 2, try to quit the driver instead of closing it (i.e. api1.driver.quit()).

iaston commented 1 year ago

In your line 2, try to quit the driver instead of closing it (i.e. api1.driver.quit()).

Thanks for advice, I'll try and report result later.

iaston commented 1 year ago

In your line 2, try to quit the driver instead of closing it (i.e. api1.driver.quit()).

After changed close() to quit(), I run the program for more than one hour and the same error still. But during the test, I found a situation, as shown in the picture. While send_message returned the error exception "list index out of range", the program called api1.driver.quit() and the chrome window was closed immediately, and then my program immediately started a 600-second sleep (as mark 1). But at this time, I saw that the console did not wait for 600 seconds, but immediately began to output 3 times "warning...Failed to establish a new connection..." after 1 second (as mark 2). This indicates that an unknown process is still trying to connect to the closed chrome?

Moreover, if this prompt appears, pychatGPT will run abnormally. While api1.send_message be called after sleep, the result will always be error exception:"list index out of range" (ps, what is the reason for this error?), and then continue with "warning...Failed to establish a new connection ...".

image

And also, what is particularly strange is that in this case my chatGPT account quickly hits the 1 hour request limit (as shown in the picture), even though there does not appear to be any valid chatGPT requests during this period.

image