carcabot / tiktok-signature

Generate tiktok signature token using node
752 stars 286 forks source link

Error: Evaluation failed: ReferenceError: Can't find variable: generateSignature on Docker #76

Closed bagastepe closed 4 years ago

bagastepe commented 4 years ago

Im getting this error in my production server, but its fine on my local pc using virtualbox. Im using Centos7 run via docker.

Received url: https://m.tiktok.com/api/item_list/?count=30&id=6526793073236934658&type=1&secUid=MS4wLjABAAAAm6dHp9IJJJ4tK8g_2Cpdw5YSCQ8ruU7alYu_RxBGU3pkO1PrJE4F55qHNY1xCWo9&maxCursor=0&minCursor=0&sourceType=8&appId=1233 Error: Evaluation failed: ReferenceError: Can't find variable: generateSignature at WKExecutionContext.evaluate (/usr/node_modules/playwright-core/lib/webkit/wkExecutionContext.js:50:23) at async FrameManager.waitForSignalsCreatedBy (/usr/node_modules/playwright-core/lib/frames.js:81:28) at async FrameExecutionContext._doEvaluateInternal (/usr/node_modules/playwright-core/lib/dom.js:42:16) at async Signer.sign (/usr/index.js:93:15) at async IncomingMessage. (/usr/listen.js:38:27) -- ASYNC -- at Frame. (/usr/node_modules/playwright-core/lib/helper.js:63:23) at Page.evaluate (/usr/node_modules/playwright-core/lib/page.js:257:33) at Page. (/usr/node_modules/playwright-core/lib/helper.js:64:31) at Signer.sign (/usr/index.js:93:31) at async IncomingMessage. (/usr/listen.js:38:27) TimeoutError: Navigation timeout exceeded while navigating to https://www.tiktok.com/@rihanna?lang=en at /usr/node_modules/playwright-core/lib/frames.js:860:37 -- ASYNC -- at Frame. (/usr/node_modules/playwright-core/lib/helper.js:63:23) at Page.goto (/usr/node_modules/playwright-core/lib/page.js:192:33) at Page. (/usr/node_modules/playwright-core/lib/helper.js:64:31) at Signer.init (/usr/index.js:58:21)

carcabot commented 4 years ago

Hi there,

This error is because generateSignature could not been initialized correctly, have you tried to run it again and got the same error ?

bagastepe commented 4 years ago

Hi there,

This error is because generateSignature could not been initialized correctly, have you tried to run it again and got the same error ?

yes. i also build the dockerfile again and change the 'waitUntil' to 'networkIdle' generate same error. might it be tiktok blocked by my server? but i can ping to tiktok.com

carcabot commented 4 years ago

If you think that TikTok blocked your server, try using a proxy or vpn when starting the server.

For proxy try this code in index.js:

...
args = [
    "--proxy-server=http://10.10.10.10:8000"
    "--no-sandbox",
    "--disable-setuid-sandbox",
    "--disable-infobars",
    "--window-position=0,0",
    "--ignore-certifcate-errors",
    "--ignore-certifcate-errors-spki-list",
  ];
...
bagastepe commented 4 years ago

If you think that TikTok blocked your server, try using a proxy or vpn when starting the server.

For proxy try this code in index.js:

...
args = [
    "--proxy-server=http://10.10.10.10:8000"
    "--no-sandbox",
    "--disable-setuid-sandbox",
    "--disable-infobars",
    "--window-position=0,0",
    "--ignore-certifcate-errors",
    "--ignore-certifcate-errors-spki-list",
  ];
...

i try using vpn proxy like in the docs still not working on my live server https://playwright.dev/#version=v1.2.1&path=docs%2Fapi.md&q=browsertypelaunchoptions--options-proxy

this.options = { args: [], ignoreDefaultArgs: ["--mute-audio", "--hide-scrollbars"], headless: true, ignoreHTTPSErrors: true, proxy:{ server:"http://10.10.10.10:80", username:'userbame@live.com', password:'xxxxxx' } };

bagastepe commented 4 years ago

i just realized my issue is like this after wait for 30 second timeout since TikTok Signature server started.

TikTok Signature server started TimeoutError: Navigation timeout exceeded while navigating to https://tiktok.com/@rihanna?lang=en at /usr/node_modules/playwright-core/lib/frames.js:860:37 -- ASYNC -- at Frame. (/usr/node_modules/playwright-core/lib/helper.js:63:23) at Page.goto (/usr/node_modules/playwright-core/lib/page.js:192:33) at Page. (/usr/node_modules/playwright-core/lib/helper.js:64:31) at Signer.init (/usr/index.js:63:21)

carcabot commented 4 years ago

Yes, you get timeout because your server cannot access tiktok.com , possibly blocked. You can pass a valid proxy and it will work.

bagastepe commented 4 years ago

solved by using vpn proxy and build docker again with --no-cache. thanks man 👍