This message was deleted.
# helpdesk
s
This message was deleted.
q
A bit more context... the error is coming from
TwirpRPC.js
calling Axios for a wss request inside folder
livekit-server-sdk > dist
TwirpRPC
is being called in
EgressClient.js
as assigned to
this.rpc
which processes the
startTrackEgress
function. And unless I've totally lost it, Axios isn't a websocket client.
m
@quiet-parrot-71005 where are you specifying your websocket URL? When you create your egress client? I haven’t personally used trackEgress over WebSocket before. Could you paste some code (with the wss URL redacted)?
d
Ah! can you try usinng https:// with the URL?
this is an oversight on our end.. the server SDK should handle this automatically
q
Thanks for the reply guys. I've got my websocket and egress client defined earlier in the function. Based on @dry-elephant-14928’s suggestion, I changed both urls to https and now don't see the Axios error, the
egress_started
event begins followed quickly by
egress_ended
with
error
field
error: 'URL was not provided',
Here is my function:
Copy code
async function livekitWebhook(req) {
    const apiKey = process.env.LIVEKIT_API;
    const secret = process.env.LIVEKIT_SECRET;
    const webhook = "https://<our-websocket-url>.<http://appspot.com|appspot.com>";
    const liveKitUrl = 'https://<our-livekit-host-url>.livekit.cloud';

    const receiver = new WebhookReceiver(apiKey, secret);
    const egressClient = new EgressClient(liveKitUrl, apiKey, secret);

    try {
        const event = receiver.receive(req.body, req.get('Authorization'));
        console.log('Received LiveKit Webhook data');
        console.log(event);

        if (event.event == 'track_published') {
            console.log('++ Event is track published, starting webhook code ++');
            
            const roomName = event.room.name;
            const trackID = event.track.sid;

            console.log('Room Name :: ' + roomName + ' :: TrackID :: ' + trackID + ' :: webhook :: ' + webhook);
            const info = await egressClient.startTrackEgress(roomName, webhook, trackID);

            console.log('--------------------------------');
            console.log('Received Info details');
            console.log(info);
            console.log('--------------------------------');
        }

        return event;
    } catch(err) {
        console.log('Error with livekit webhook');
        console.log(err);
        return err;
    }
}
I believe I've structured
EgressClient(liveKitUrl, apiKey, secret)
and
egressClient.startTrackEgress(roomName, webhook, trackID);
and I see the egress started / stopped in the livekit console.. but now I don't know where else it's missing the URL 😅 slowly progressing though
also, we just went for the premium account to support the cause! ❤️
so the websocket url can be
wss
but not the livekitURL which has to be
https
- so now I'm getting pings on my websocket. with an EOF error I'm working through, according to the livekit console:
websocket: close 1006 (abnormal closure): unexpected EOF
d
is this an audio or video track that you are attempting to Egress?
TrackEgress to websocket only works for audio.
q
yes audio only, for STT purposes
d
ok, good. then the error indicates there's most likely an issue with your websocket receiver
as written, your code will attempt to start Egress for every track in the room, including video tracks.. you'd want to check in
Copy code
if (event.event == 'track_published') {
that it's an audio track, before attempting
🙏 1
q
is that just a matter of checking the event.track.mimetype value?
probably:
Copy code
const mimeType = event.track.mimeType;
if (mimeType == 'audio/x-raw') {
const info = await egressClient.startTrackEgress(roomName, webhook, trackID);
}
d
you'd want to check track.type. the MIME will not be
audio/x-raw
either, as the client has published opus
q
aha very useful. thank you
I just saw I'm getting mimeType of audio/red.. I'll switch over to track.type