carriejv / cytube-client

A NodeJS Cytu.be (sync) Client
MIT License
5 stars 1 forks source link

Error: cytube-client: Request timed out. #15

Closed FelixLttks closed 1 year ago

FelixLttks commented 1 year ago

Hello, i cant get it to run..

When I execute the following code I recieve an error message. Any idea how to fix this?

var cytube = require('cytube-client');

var options = {
    // This is REQUIRED. Sync will not acknowledge connections without a specified channel.
    channel: 'abc',
    secure: true,
    reconnect: true,
    socketServer: 'https://bigapple.cytu.be:8443',
    timeout: 15000
};

cytube.connect(options, (err, client) => {

    if(err) {
        console.log(err);
    }

    client.getCurrentMedia((err, data) => {
        if(err) {
            // Handle timeout or disconnect.
        }
        else {
            console.log(data);
        }
    });

    client.on('changeMedia', (data) => {
        console.log(data);
    });
});

Error:

c:\Users\[USER]\node_modules\cytube-client\index.js:78
            reject(new Error(ERR_PREFIX + 'Request timed out.'));
                   ^

Error: cytube-client: Request timed out.
    at Timeout._onTimeout (c:\Users\[USER]\node_modules\cytube-client\index.js:78:11)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

Node.js v18.15.0

could be that cytube changed the internal API?

carriejv commented 1 year ago

I'm able to run integration tests against cytu.be. Could be an actual connection issue to the server you're trying to reach? Is it public? I can try to reproduce the issue myself if so.

FelixLttks commented 1 year ago

Maybe I dont quite understand what Im suuppost to do.

I configured socketServer by looking at what https://cytu.be/socketconfig/abc.json returns. This returns:

{"servers":[{"url":"https://bigapple.cytu.be:8443","secure":true},{"url":"http://bigapple.cytu.be:8880","secure":false}]}

now I thought I just had to put 'https://bigapple.cytu.be:8443' as the socketServer when setting secure: true.

Is this correct?

carriejv commented 1 year ago

Oh, I see the issue. Cytu.be doesn't have a 404 (or any kind of error messaging) if you try to connect to a channel that doesn't exist. abc doesn't have media playing so cytu.be just never answers. It's a bit of a misleading error, but I'm not sure if there's a way to handle it any better.

Unrelated, but you don't have to manually specify the socket server either if you're connecting to cytu.be. That's only there for self-hosted servers, etc. It will do the socket lookup for you with just channel.

FelixLttks commented 1 year ago

Thank you. That fixes my error :)