-
Notifications
You must be signed in to change notification settings - Fork 12
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: Can't send data because WebSocket is not opened #38
Comments
Use separate work folders for each process, this can help to avoid such errors: |
@Wizzzz Greetings, try to check the following algorithm, perhaps one of the node processes has not completed and is holding a lock, which causes an error:
Just in case, I recommend that you ALWAYS close the browser using the If the problem does not repeat itself, then the processes can still be open when you run your code - there is a timer in the client to automatically turn off the engine after 5 minutes, you can simply force the current process to end upon completion. Or do additional management before starting - check if there is another process that used the same folder, and if there is, then kill it. You can also try importing a list of locks from the When I have time for fixes and updates, I will try to find another package for locks inside the plugin instead of the current one, because of it there are too many problems and too often. Anyway, I hope my advice will help you a little. |
@CheshireCaat Will deleting the .lock file unblock the situation? Technically, with my DB, it's impossible for 2 processes to use the same engine. So I can make sure that before starting a browser, I check the existence of the .lock file and if it exists, delete it. If everything is well managed in my DB, there won't be any problems? |
@Wizzzz you can try to remove lock file, but there is no guarantee that it complete release it for the target proccess. At least, if it will not work, you can try other advices from the my previous comment.
In theory, taking into account the rest of the recommendations, everything should be fine. |
@CheshireCaat Is there a discord or a telegram group with other users of your packages? It might be cool to have one to discuss how we can implement a common solution to face its problems since we are several to have it. |
Is there an example of the solution you propose? Because I'm not sure I've understood 100% of the different steps. ;( |
Hello, I'm opening this issue because I have a problem with playwright-with-fingerprint. After a few uses, I get an error when generating a browser and I have to stop my nodejs and restart it.
I've been trying to fix the error myself for a while now, but it's impossible, so I'm relying on you.
Here's the error in question:
Error: Can't send data because WebSocket is not opened. at exports.throwIf (C:\Users\Administrator\Desktop\project\node_modules\websocket-as-promised\src\utils.js:4:11) at WebSocketAsPromised.send (C:\Users\Administrator\Desktop\project\node_modules\websocket-as-promised\src\index.js:252:5) at SocketService.send (C:\Users\Administrator\Desktop\project\node_modules\bas-remote-node\src\services\socket.js:89:14) at BasRemoteClient._send (C:\Users\Administrator\Desktop\project\node_modules\bas-remote-node\src\index.js:223:25) at BasRemoteClient.send (C:\Users\Administrator\Desktop\project\node_modules\bas-remote-node\src\index.js:254:17) at BasRemoteClient._startThread (C:\Users\Administrator\Desktop\project\node_modules\bas-remote-node\src\index.js:275:10) at C:\Users\Administrator\Desktop\project\node_modules\bas-remote-node\src\index.js:190:12 at new Promise (<anonymous>) at BasRemoteClient.runFunction (C:\Users\Administrator\Desktop\project\node_modules\bas-remote-node\src\index.js:189:21) at C:\Users\Administrator\Desktop\project\node_modules\browser-with-fingerprints\src\plugin\connector\index.js:31:16
To solve the problem, I have to close my program and restart it.
I've noticed that this error occurs if I have other programs that use playwright-with-fingerprint, but if I don't have any other nodes that use the plugin, I never get the error.
Here's my class for managing browsers:
`
import { FetchOptions } from "browser-with-fingerprints";
import fs from "fs";
import path from "path";
import { BrowserContext } from "playwright-core";
import { plugin } from "playwright-with-fingerprints";
import { Logger } from "../../logger";
import { Proxy } from "../../proxy";
import { BrowserOptions } from "../../types/browser";
import { capsolverDefaultConfig, CapsolverOptions } from "../../types/capsolver";
import { nopechaDefaultConfig, NopechaOptions } from "../../types/nopecha";
import { sleep } from "../../utils";
type InstanceOptions = {
browserOptions: BrowserOptions;
capsolverOptions?: CapsolverOptions;
c;
nopechaOptions?: NopechaOptions;
proxy?: Proxy;
};
type PageOptions = {
blockImageDomains?: string[];
};
export class BrowserInstance {
private browser: BrowserContext | null = null;
readonly instanceOptions: InstanceOptions;
}
`
Thank advance !
The text was updated successfully, but these errors were encountered: