Skip to content

Commit

Permalink
Merge pull request #120 from erictik/proxy
Browse files Browse the repository at this point in the history
Proxy
  • Loading branch information
zcpua authored Jun 15, 2023
2 parents 9e89b12 + 0a0dae5 commit d5f11df
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/releases.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Node.js Package
env:
APPVERSION: v2.6.${{ github.run_number }}
APPVERSION: v2.7.${{ github.run_number }}
on:
workflow_dispatch:
push:
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "midjourney",
"version": "2.6.0",
"version": "2.7.0",
"description": "Node.js client for the unofficial MidJourney API.",
"main": "libs/index.js",
"types": "libs/index.d.ts",
Expand Down Expand Up @@ -45,7 +45,6 @@
},
"dependencies": {
"@huggingface/inference": "^2.5.0",
"https-proxy-agent": "^7.0.0",
"isomorphic-ws": "^5.0.0",
"mime": "^3.0.0",
"p-queue": "^6.6.2",
Expand Down
14 changes: 7 additions & 7 deletions src/ws.message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { MidjourneyApi } from "./midjourne.api";
import { VerifyHuman } from "./verify.human";
import WebSocket from "isomorphic-ws";
import { HttpsProxyAgent } from "https-proxy-agent";
// import { HttpsProxyAgent } from "https-proxy-agent";

export class WsMessage {
ws: WebSocket;
Expand All @@ -21,14 +21,14 @@ export class WsMessage {
private waitMjEvents: Map<string, WaitMjEvent> = new Map();
private reconnectTime: boolean[] = [];
private heartbeatInterval = 0;
agent?: HttpsProxyAgent<string>;
// agent?: HttpsProxyAgent<string>;

constructor(public config: MJConfig, public MJApi: MidjourneyApi) {
if (this.config.ProxyUrl && this.config.ProxyUrl !== "") {
this.agent = new HttpsProxyAgent(this.config.ProxyUrl);
// this.agent = new HttpsProxyAgent(this.config.ProxyUrl);
}
const agent = this.agent;
this.ws = new WebSocket(this.config.WsBaseUrl, { agent });
// const agent = this.agent;
this.ws = new WebSocket(this.config.WsBaseUrl);
this.ws.addEventListener("open", this.open.bind(this));
}

Expand All @@ -52,8 +52,8 @@ export class WsMessage {
//try reconnect
private reconnect() {
if (this.closed) return;
const agent = this.agent;
this.ws = new WebSocket(this.config.WsBaseUrl, { agent });
// const agent = this.agent;
this.ws = new WebSocket(this.config.WsBaseUrl);
this.ws.addEventListener("open", this.open.bind(this));
}
// After opening ws
Expand Down
27 changes: 0 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,6 @@ acorn@^8.4.1:
resolved "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz"
integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==

agent-base@^7.0.2:
version "7.1.0"
resolved "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz"
integrity sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==
dependencies:
debug "^4.3.4"

arg@^4.1.0:
version "4.1.3"
resolved "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz"
Expand All @@ -235,13 +228,6 @@ create-require@^1.1.0:
resolved "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz"
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==

debug@4, debug@^4.3.4:
version "4.3.4"
resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"

diff@^4.0.1:
version "4.0.2"
resolved "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz"
Expand Down Expand Up @@ -295,14 +281,6 @@ get-tsconfig@^4.4.0:
resolved "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.5.0.tgz"
integrity sha512-MjhiaIWCJ1sAU4pIQ5i5OfOuHHxVo1oYeNsWTON7jxYkod8pHocXeh+SSbmu5OZZZK73B6cbJ2XADzXehLyovQ==

https-proxy-agent@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.0.tgz#75cb70d04811685667183b31ab158d006750418a"
integrity sha512-0euwPCRyAPSgGdzD1IVN9nJYHtBhJwb6XPfbpQcYbPCwrBidX6GzxmchnaF4sfF/jPb74Ojx5g4yTg3sixlyPw==
dependencies:
agent-base "^7.0.2"
debug "4"

isomorphic-ws@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz"
Expand All @@ -318,11 +296,6 @@ mime@^3.0.0:
resolved "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz"
integrity sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==

[email protected]:
version "2.1.2"
resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

p-finally@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz"
Expand Down

0 comments on commit d5f11df

Please sign in to comment.