yxw21 / chatgpt

chatgpt api
9 stars 0 forks source link

Gives context deadline exceeded #5

Closed aminalipour closed 1 year ago

aminalipour commented 1 year ago

Hello i got the key from https://nopecha.com but not working using 0.6.0 login to chatgpt failed: wait for .btn:nth-child(1) element error: context deadline exceeded thanks

yxw21 commented 1 year ago

This is because this login behavior was recognized by cloudflare as a bot that could not pass the check. Please retry the login several times. For example


package main

import (
    "fmt"
    "github.com/yxw21/chatgpt"
)

func main() {
    retry := 3
    // Make sure the session is initialized once
    session := chatgpt.NewSessionWithAccessToken("AccessToken").AutoRefresh()
    chat := chatgpt.NewChat(session)
    for i := 0; i < retry; i++ {
        res, err := chat.Send("hi")
        if err == nil{
            fmt.Println(res.Message.Content.Parts)
            break
        }
        if i == retry - 1 {
            fmt.Println(err)
        }
    }
}
aminalipour commented 1 year ago

something is wrong with nopecha.com extention and key,if i try with I-xxxxxxxx it will get error at recaptcha in login form : login to chatgpt failed: solve the reCAPTCHA error: context deadline exceeded if try with xxxxxxxxxx_xxxxxxx it get error at firsr step: login to chatgpt failed: wait for .btn:nth-child(1) element error: context deadline exceeded but nopecha.com gave me xxxxxxxxxx_xxxxxxx not I-xxxxxxxx

yxw21 commented 1 year ago

Sometimes you will get login to chatgpt failed: solve the reCAPTCHA error: context deadline exceeded error. So you can retry a few times. The key format I got is I-xxxxxx, not sure if your key format is the same as mine. Just fill in the correct key. If you get an error please try several times.

aminalipour commented 1 year ago

also i think you need to set key value with access token way, it need to bypass cloudflare captcha

On Sat, Dec 24, 2022 at 6:11 AM yxw21 @.***> wrote:

Sometimes you will get login to chatgpt failed: solve the reCAPTCHA error: context deadline exceeded error. So you can retry a few times. The key format I got is I-xxxxxx, not sure if your key format is the same as mine. Just fill in the correct key. If you get an error please try several times.

— Reply to this email directly, view it on GitHub https://github.com/yxw21/chatgpt/issues/5#issuecomment-1364445355, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFVAUF7R3B6ZNN4SSABPWHLWOZPELANCNFSM6AAAAAATIFRTNE . You are receiving this because you authored the thread.Message ID: @.***>

yxw21 commented 1 year ago

Currently I use a third-party library to emulate a normal browser to bypass cloudflare checks. And most of the time it works well. cloudflare once you recognize that you are automated is less easy to automate bypass. Currently as far as possible so that cloudflare can not find you are automated. If you retry a few times after still can not you can change the ip. suggest you increase the number of retries.