Coder Social home page Coder Social logo

Proxy error about googlebard HOT 5 CLOSED

pawanosman avatar pawanosman commented on May 15, 2024
Proxy error

from googlebard.

Comments (5)

PawanOsman avatar PawanOsman commented on May 15, 2024

can you show us an example of how you used the proxy settings?

from googlebard.

tockawaffle avatar tockawaffle commented on May 15, 2024

I was using the proxy setting on the package as described in the readme:

import { Bard } from "googlebard";

export default async function orchestra() {
    const importDynamic = new Function(
        "modulePath",
        "return import(modulePath)"
    );
    const { Bard } = await importDynamic("googlebard");
    const choirs = new Bard(`__Secure-1PSID="${process.env.BARD_COOKIE!}"`, {
        proxy: {
            host: process.env.BARD_PROXY_HOST!,
            port: process.env.BARD_PROXY_PORT!,
            auth: {
                username: process.env.BARD_PROXY_USERNAME!,
                password: process.env.BARD_PROXY_PASSWORD!,
            },
            protocol: "http",
        },
    });
    return choirs as Bard;
}

That would throw the default error of the package, asking to check the cookie that was set, but with some digging and logging I could find the actual error:
AxiosError: Request failed with status code 502
With the Squid info below it:

</head><body id=ERR_READ_ERROR>\n' +
      '<div id="titles">\n' +
      '<h1>ERROR</h1>\n' +
      '<h2>The requested URL could not be retrieved</h2>\n' +
      '</div>\n' +
      '<hr>\n' +
      '\n' +
      '<div id="content">\n' +
      '<p>The following error was encountered while trying to retrieve the URL: <a href="https://bard.google.com/">https://bard.google.com/</a></p>\n' +
      '\n' +
      '<blockquote id="error">\n' +
      '<p><b>Read Error</b></p>\n' +
      '</blockquote>\n' +
      '\n' +
      '<p id="sysmsg">The system returned: <i>[No Error]</i></p>\n' +
      '\n' +
      '<p>An error condition occurred while reading data from the network. Please retry your request.</p>\n' +

The proxy is being used with the default configuration, I can see it on the proxy object on the error thrown: AxiosError.log

The solution I found was to use:

import HttpsProxyAgent from "https-proxy-agent";
let axiosOptions = {
          proxy: false,
          httpsAgent: new HttpsProxyAgent(`http://user:password@ip:port`),
          headers: {
              "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0",
              Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
              "Accept-Language": "en-US,en;q=0.5",
              "Accept-Encoding": "gzip, deflate, br",
              Connection: "keep-alive",
              "Upgrade-Insecure-Requests": "1",
              "Sec-Fetch-Dest": "document",
              "Sec-Fetch-Mode": "navigate",
              "Sec-Fetch-Site": "none",
              "Sec-Fetch-User": "?1",
              TE: "trailers",
          },
};

This error is being thrown at the GetRequestParams() function, this might be an Axios error, look here

Since I changed it directly on the package's code, I didn't do any additional configuration on my end, only changed that part of the code and used it.
Also, I'm not sure if this would impact someone else since most people would use a public proxy and not a private one, so you can close this issue if you find that it woudn't impact most users.

from googlebard.

PawanOsman avatar PawanOsman commented on May 15, 2024

Thank you, can you confirm that the proxy protocol you used is http? maybe its https and you need to set the protocol to https

from googlebard.

tockawaffle avatar tockawaffle commented on May 15, 2024

Nope, my proxy is http.
When I try using it with https, this gets thrown:

cause: Error: write EPROTO 984C0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:355:
  
      at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) {
    errno: -4046,
    code: 'EPROTO',
    syscall: 'write'
  }

from googlebard.

tockawaffle avatar tockawaffle commented on May 15, 2024

Since it's not an error caused by this package itself, and I just wanted to document for further references, I'll close this issue.
Thanks!

from googlebard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.