Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
134 stars 2 forks source link

SignalR receiving events every 5 seconds from ReceiveSessionUpdate event #2621

Open LeCloutPanda opened 2 months ago

LeCloutPanda commented 2 months ago

Describe the bug?

I don't know if this is a bug or what but I wanna say it is but a few months back I noticed session events on trigger every 30 seconds or so and now it's triggering every five seconds, I was about to check but just check the time stamps of a session when it appeared again and I believe this isn't intended.

To Reproduce

Use SignalR either in game or external and look for the ReceiveSessionUpdate event and notice how it triggers every 5 seconds.

Expected behavior

Not to trigger every 5 seconds but instead every 30 seconds to minimize bandwidth use and still have a consistent flow of updates.

Screenshots

N/A

Resonite Version Number

2024.7.17.1173

What Platforms does this occur on?

Windows, Linux

What headset if any do you use?

Desktop

Log Files

N/A can't really supply log files if it is a SignalR thing that can be used outside of the platform.

Additional Context

I used a custom app to read the SignalR events but I don't doubt the same events are going through Resonite when sessions are updated

Reporters

LeCloutPanda (Discord)

Frooxius commented 2 months ago

This seems normal. SignalR and session updates are sent whenever something changes, not at regular intervals, because it's a push notification system.

The more sessions there are and the more people change things, the more updates you'll get. They're relatively small though, so there's not really a big concern. If someone spams things too much, they should get rate limited.

LeCloutPanda commented 2 months ago

I understand that but I get all the sessions when it sends the update rather than the sessions that actually updated, when looking at specific sessions between updates they stay the same so something is for sure wrong here and isn't sending the updated sessions and instead is sending all of them again.

Frooxius commented 2 months ago

It should only send the session that actually updated. I don't really know what exactly you're doing - you haven't provided any logs or details, just a general verbal description, so there's not much I can do here.

If you can provide any details, I can have a look, but without knowing specifics, I can't do much.

LeCloutPanda commented 1 month ago

Sorry I've been busy so I haven't really had time to follow this up but I've done some testing where I've hosted a headless, nothing updating as in nothing is actively happening because no one is in the session so nothing should update.

Anyways I recorded this data.

===== Session Update =====
Session Name: Test Server
Session Host: U-AmogOS
User Count: 0
Time Stamp: 00:07:36.3636 AEST
==========================

===== Session Update =====
Session Name: Test Server
Session Host: U-AmogOS
User Count: 0
Time Stamp: 00:07:41.4141 AEST
==========================

===== Session Update =====
Session Name: Test Server
Session Host: U-AmogOS
User Count: 0
Time Stamp: 00:07:46.4646 AEST
==========================

===== Session Update =====
Session Name: Test Server
Session Host: U-AmogOS
User Count: 0
Time Stamp: 00:07:51.5151 AEST
==========================

===== Session Update =====
Session Name: Test Server
Session Host: U-AmogOS
User Count: 0
Time Stamp: 00:07:56.5656 AEST
==========================

The updates are coming through every 5 seconds which is a waste of resources, it wouldn't be if it worked correctly when a session actually updates but the session was sitting there doing nothing so no updates should have been happening.

This is my very basic code to interact with signalr and the update session event.

import signalR from '@microsoft/signalr';
import dateFormat, { formatTimezone, masks } from "dateformat";

let signalRConnection;

async function startSignalR() {
    signalRConnection = new signalR.HubConnectionBuilder()
    .withUrl(`https://api.resonite.com/hub`)
    .withAutomaticReconnect()
    .configureLogging(signalR.LogLevel.Critical)
    .build();

    await signalRConnection.start().catch(async (error) => {
        console.error(error);
        throw error;
    })

    signalRConnection.on("ReceiveSessionUpdate", async (session) => {

        var date = dateFormat(Date.now(), "HH:mm:ss.sss Z");

        if (session["hostUserId"] == "U-AmogOS") { 
            console.log("===== Session Update =====");
            console.log(`Session Name: ${session["name"]}`);
            console.log(`Session Host: ${session["hostUserId"]}`);
            console.log(`User Count: ${session["sessionUsers"].length}`);
            console.log(`Time Stamp: ${date}`);
            console.log("==========================\n");
            await createSessionEntry(session);
        }
    })
}

startSignalR();

To wrap this up sessions shouldn't be resent if nothing actually is happening. I could be wrong here so please provide how it determines that a session has updated because again in my opinion it shouldn't be updating this quickly for a session that isn't doing anything.

Frooxius commented 1 month ago

Did you do any diffs for the received data to see if there's really nothing changing?

The way the system is written, it will only generate updates if it detects that any of the parameters have changed - and then on top of that it'll send update every now and then.

I don't see anything in the data that would indicate that nothing really changed - it's possible that a parameter actually is changing, forcing the updates.

LeCloutPanda commented 1 month ago

Just did a diff check and the only variables that were different was the lastUpdate variable, if that is all that is being changed then this issue might be more then that and something to do with how sessions update needs to be updated.

image

Frooxius commented 1 month ago

Thanks! Yeah, if nothing else is changing, then there's likely something that's triggering updates when it shouldn't.

Do you have logs from the host of the session? They can indicate on why is session info being updated.

LeCloutPanda commented 1 month ago

Here are the few logs I have, I literally set the headless up just for this so it's brand new GEOFF - 2024.7.22.1319 - 2024-07-25 00_00_10.log GEOFF - 2024.7.22.1319 - 2024-07-24 23_51_45.log GEOFF - 2024.7.22.1319 - 2024-07-25 00_14_36.log