Skip to content
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

Client network socket disconnected before secure TLS connection was established #5

Open
chinlee1523 opened this issue Jun 20, 2023 · 0 comments

Comments

@chinlee1523
Copy link

chinlee1523 commented Jun 20, 2023

node -v
v20.2.0
报错:
Error: Client network socket disconnected before secure TLS connection was established
at connResetException (node:internal/errors:714:14)
at TLSSocket.onConnectEnd (node:_tls_wrap:1615:19)
at TLSSocket.emit (node:events:523:35)
at endReadableNT (node:internal/streams/readable:1367:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
Waiting for the debugger to disconnect...

代码
const proxyFetch: FetchFn = async (
input: RequestInfo | URL,
init?: RequestInit | undefined
): Promise => {
const agent = new SocksProxyAgent("socks5://127.0.0.1:7890", {
keepAlive: true,
});
if (!init) init = {};
// @ts-ignore
init.agent = agent;
// @ts-ignore
return fetch(input, init);
};

  class ProxyWebSocket extends WebSocket {
    constructor(address: string | URL, options?: WebSocket.ClientOptions) {
      const agent = new SocksProxyAgent("socks5://127.0.0.1:7890", {
        keepAlive: true,
      });
      if (!options) options = {};
      options.agent = agent;
      super(address, options);
    }
  }

  this.client = new Midjourney({
    // MaxWait: 1000000,
    ServerId: "662267976984324324",
    ChannelId: "10085712443242346",
    SalaiToken:
      "MTExN",
    Debug: true,
    Ws: true,
    fetch: proxyFetch,
    WebSocket: ProxyWebSocket as typeof WebSocket,
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant