Closed ramosmikel closed 1 year ago
Good day, try deleting the data
folder where the plugin engine is stored.
If nodemon reacts to changes in this folder, you should definitely add it to the exceptions - it's very dangerous to use it without proper configuration, since plugins constantly change files in the engine folder during work. This may not only interrupt the browser download, but also lead to other problems.
After that, run your project and wait for the browser to fully load. If that doesn't help, please let me know.
Please can you also tell me where the Profiles are getting installed so I can add the path into nodemon excluded paths.
Please, first of all, use the documentation and sources of the original framework for this - i.e. the puppeteer package. For simplicity, you can open the chrome://version
URL in the browser - the current profile will be indicated there.
The frameworks themselves set the necessary paths to the profiles, unless you specify otherwise.
The main thing, as I wrote above, is to exclude the folder with the engine - by default it's created in the data
folder of the working directory.
I removed data folder that contains engine then again redownload browser but it doesn't help. chrome://version contains this profile path - > Profile Path: C:\Users\User\AppData\Local\Google\Chrome\User Data\Default
Thank you for your reply. I had assumed that the installation referred to creating new profiles, which led to my request for the folder path not relating to puppeteer but to the installation.
I appreciate your suggestion to delete the data folder where the plugin engine is stored. I did not initially notice its presence and nodemon ignores it by default. It is possible that the app crashed during installation and failed to log an error, since it already ignores anything outside the src folder.
Thank you for bringing this to my attention and for your help in resolving that issue.
Unfortunately, I have encountered one more issue, which is that the fingerprints are not downloading.
Please find the test fingerprint file below:
"{\"valid\":false,\"message\":\"Key is empty\"}"
Please find my code below: [config is being properly loaded]
this.KEY = ""
this.TAGS= ["Microsoft Windows", "Chrome"];
this.TIME_LIMIT = "15 days"
import { join } from "path";
import { writeFile, access, mkdir } from "fs-extra";
import { plugin } from "puppeteer-with-fingerprints";
import { Tag, Time } from "browser-with-fingerprints";
import { config } from "../../config";
export interface FingerprintManagerConfig {
key: string;
tags: Tag[];
timeLimit: Time;
storagePath?: string;
}
interface CreateFingerprintArgs {
key: string;
}
export interface CreateFingerprintData {
key: string;
path: string;
}
type Fingerprint = any;
const FINGERPRINTS_STORAGE_PATH = join(process.cwd(), "fingerprints");
export class FingerprintManager {
private STORAGE_PATH: string;
private KEY: string;
private TAGS: Tag[];
private TIME_LIMIT: Time;
constructor(config: FingerprintManagerConfig) {
this.KEY = config.key;
this.TAGS = config.tags;
this.TIME_LIMIT = config.timeLimit;
this.STORAGE_PATH = config.storagePath ?? FINGERPRINTS_STORAGE_PATH;
}
public async createFingerprint({ key }: CreateFingerprintArgs): Promise<CreateFingerprintData> {
const fileName: string = `${key}.json`;
const path: string = join(this.STORAGE_PATH, fileName);
if (await this.isFingerprintExists(path)) {
throw new Error(`Fingerprint with key "${key}" already exists`);
}
try {
const fingerprint: Fingerprint = await this.fetchFingerprint();
await this.writeFileWithCheck(path, JSON.stringify(fingerprint));
return {
key,
path,
};
} catch (error: unknown) {
if (error instanceof Error) {
throw new Error(
`Failed to save fingerprint with key "${key}": ${error.message}`
);
} else {
throw new Error(
`Failed to save fingerprint with key "${key}": Unknown error`
);
}
}
}
private async isFingerprintExists(path: string): Promise<boolean> {
try {
await access(path);
return true;
} catch {
return false;
}
}
private async fetchFingerprint(): Promise<Fingerprint> {
try {
return await plugin.fetch(this.KEY, {
tags: this.TAGS,
timeLimit: this.TIME_LIMIT,
});
} catch (error: unknown) {
if (error instanceof Error) {
throw new Error(`Failed to fetch fingerprint: ${error.message}`);
} else {
throw new Error(`Failed to fetch fingerprint: Unknown error`);
}
}
}
private async writeFileWithCheck(path: string, content: string): Promise<void> {
const directory = join(this.STORAGE_PATH);
try {
await access(directory);
} catch {
await mkdir(directory, { recursive: true });
}
await writeFile(path, content);
}
}
(async () => {
try {
const manager: FingerprintManager = new FingerprintManager({
key: config.fingerprints.secret,
tags: config.fingerprints.tags,
timeLimit: config.fingerprints.timeLimit,
});
const fingerprintData: FingerprintData = await manager.createFingerprint({
key: 'test',
});
console.log(`Fingerprint created with path ${fingerprintData.path}`);
} catch (error: unknown) {
if (error instanceof Error) {
console.error(`Error creating fingerprint: ${error.message}`);
} else {
console.error(`Error creating fingerprint: Unknown error`);
}
}
})();
With free version it is possible to use only ['Microsoft Windows', 'Chrome'] tags
@bablosoft I am using the below:
const tags: Tag[] = ["Microsoft Windows", "Chrome"];
const timeLimit: Time = "15 days";
You need to use ['Microsoft Windows', 'Chrome'] tags and exclude all filters.
https://github.com/CheshireCaat/puppeteer-with-fingerprints/blob/master/README.md?plain=1#L349
Thank you issue solved
@bablosoft Can you fix this problem? I have key and when i upload to vps, I'm alway got this error
@minhdv92 Please create the new issue, attach: full source code, version, that you are using, steps to reproduce, all required data. Do not post your key.
Issue Description:
I'm encountering an error while attempting to run the example code in the repository. Specifically, I'm receiving the following error message: "Error: Cannot connect to the WebSocket server" with a reference to a specific file and line number. The error occurs after running the code once and then nodemon restarted since it was then installing the browser.
Error: Cannot connect to the WebSocket server at [C DRIVE]...node_modules\bas-remote-node\src\services\socket.js:55:18 at Timeout._onTimeout ([C DRIVE]...node_modules\chnl\dist\channel.cjs.js:2:4848) at listOnTimeout (node:internal/timers:564:17) at processTimers (node:internal/timers:507:7)
I have attached a full copy of the console below. node.txt
Please can you also tell me where the Profiles are getting installed so I can add the path into nodemon excluded paths.