Skip to content

Commit

Permalink
change fetch to ws
Browse files Browse the repository at this point in the history
  • Loading branch information
wont-stream committed Sep 26, 2024
1 parent 6c52a32 commit 5398d36
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/transports/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import { parse } from "node:querystring";
const portRange = [6463, 6472];

const checkIfOpen = async (port) => {
try {
await fetch(`http://localhost:${port}`);
return true;
} catch (e) {
return false;
}
new Promise((resolve) => {
const ws = new WebSocket(`ws://localhost:${port}`);

ws.onopen = () => {
ws.close();
resolve(true);
}

ws.onerror = () => {
resolve(false);
}
})
};

const getPort = async () => {
Expand Down

0 comments on commit 5398d36

Please sign in to comment.