zerodytrash / TikTok-Live-Connector

Node.js library to receive live stream events (comments, gifts, etc.) in realtime from TikTok LIVE.
https://discord.gg/2c6kX6g3Pa
MIT License
1.35k stars 279 forks source link

TypeError: ProxyAgent is not a constructor #165

Open nitsik opened 9 months ago

nitsik commented 9 months ago

I use somthing like this:


// Create a new wrapper object and pass the username
//let tiktokLiveConnection = new WebcastPushConnection(tiktokUsername);

const ProxyAgent = require('proxy-agent');

let tiktokLiveConnection = new WebcastPushConnection('@1223', {
    requestOptions: {
        httpAgent: new ProxyAgent('http://login:pass@123.123.123.123:123'),
        timeout: 10000 // 10 seconds
    },
    websocketOptions: {
        agent: new ProxyAgent('http://login:pass@123.123.123.123:123'),
        timeout: 10000 // 10 seconds
    }
});

But I see:

node tiktok.js
/root/tiktok.js:43
        httpAgent: new ProxyAgent('http://login:pass@123.123.123.123:123'),
                   ^

TypeError: ProxyAgent is not a constructor
    at Object.<anonymous> (/root/tiktok.js:43:20)
    at Module._compile (node:internal/modules/cjs/loader:1255:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1309:10)
    at Module.load (node:internal/modules/cjs/loader:1113:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

Node.js v20.2.0

Why? Thank you

yudimanage commented 5 months ago
// Create a new wrapper object and pass the username
//let tiktokLiveConnection = new WebcastPushConnection(tiktokUsername);

const { ProxyAgent } = require('proxy-agent');

let tiktokLiveConnection = new WebcastPushConnection('@1223', {
    requestOptions: {
        httpAgent: new ProxyAgent('http://login:pass@123.123.123.123:123'),
        timeout: 10000 // 10 seconds
    },
    websocketOptions: {
        agent: new ProxyAgent('http://login:pass@123.123.123.123:123'),
        timeout: 10000 // 10 seconds
    }
});