Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Connecting to a very high traffic websocket server stalls #1873

Open
Gunni opened this issue Oct 13, 2021 · 19 comments
Open

[bug]: Connecting to a very high traffic websocket server stalls #1873

Gunni opened this issue Oct 13, 2021 · 19 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Gunni
Copy link

Gunni commented Oct 13, 2021

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to realtime
  2. Paste url wss://ris-live.ripe.net/v1/ws/?client=hoppscotch.io
  3. Observe connect is disabled
  4. Remove parameter, quickly undo it and click connect (also a bug)
  5. Send { "type": "ris_subscribe" } to the remote server
  6. Observe you receive routes
  7. Observe program freezing
  8. Observe you only see like 5 messages

Expected behavior
ris-live is a stream of bgp announcements on the internet, with the { "type": "ris_subscribe" } we don't filter it at all, there are over a thousand messages per second.

Screenshots
Stalls at this point
Stalls at this point

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Browser PWA installed with Firefox
  • Version 93

Additional context
Parameters on wss urls is considered invalid, but f.ex ris-live requires it.

@AndrewBastin
Copy link
Member

Thank you for opening the issue.

We will try to resolve it as soon as possible.
Meanwhile, if anyone wants to pick this up feel free to!

@AndrewBastin AndrewBastin added hacktoberfest Hacktoberfest good first issue Good for newcomers bug Something isn't working labels Oct 14, 2021
@liyasthomas liyasthomas removed the hacktoberfest Hacktoberfest label Nov 16, 2021
@AndrewBastin AndrewBastin self-assigned this Dec 14, 2021
@KaviiSuri
Copy link

Hey, I'd love to contribute to this issue. Is it still available?

@AndrewBastin
Copy link
Member

@KaviiSuri You can take this on if you want!

Assigning to you!

@KaviiSuri
Copy link

KaviiSuri commented Mar 8, 2022

Thanks @AndrewBastin!

I'll need some guidance as I'm new to opensouce.

I was thinking of solving this by rate limiting the number of messages received (we could make the limits configurable from UI)

Sort of how this library implements it (appears to be for the backend though)
https://github.com/jamen/ws-rate-limit/blob/master/index.js

The gist of it is:

  • setup a interval to set messageCount to 0 every duration seconds
  • maintain a message count and update it
  • wrap all listeners with a function that only calls them if limit hasn't been reached, ignores if it has.

@Gunni
Copy link
Author

Gunni commented Mar 8, 2022

Maybe as a first step, but why not just handle the load gracefully?

The rislive website can do it, with no filtering at all (host = null), i get a ~20 mbit/s flow of messages, and it works fine.

Wireshark can capture all packets my computer is sending/receiving and is only limited by available memory on my computer.

@KaviiSuri
Copy link

KaviiSuri commented Mar 9, 2022

I'll look into their website on how they do it.

Do you have any ideas on what the bottleneck might be for us?

It might be the rerenders due to state update, will experiment a bit

@AndrewBastin
Copy link
Member

AndrewBastin commented Mar 9, 2022

@KaviiSuri feel free to ask for help, you can also DM me directly on Discord if you want any help or have questions about the codebase and how stuff work (you can find me in the Hoppscotch Discord Server).

@Gunni As for the approach, I actually gave a crack at this issue long back (the branch is really stale now), the main bottleneck with the rapid firing sources on Hoppscotch turns out isn't the memory issues, but more related to how Vue functions and how much time Vue spends on diffing the Log component. The RIS Live site you mentioned also doesn't render all the entries below (as mentioned by its disclaimer) and instead just renders a static number of them.

  1. When we have a lot of data accumulated, the Log component values get really big. Vue tries to diff against that and starts to fail catching up during which more updates accumulate which freezes the entire operation.
  2. We tried buffering updates (not ignoring, but collect a buffer for a certain period of time to batch updates), but even then at some point it just gave up.

A solution could be to virtualize the log component list so the only viewable logs get rendered (fixes diffing time to a constant value) along with small practices like buffering and stuff. We can still track render times (ticks) and see if we are lagging behind and then drop messages if so.

Internally though, we already have plans to rework the Realtime pages a bit and add some more features and some optimizations. You can still work on this if you want in case we couldn't fix it on our internal cycle.

@ashiishme
Copy link

Hello @AndrewBastin, I would like to take over this issue if it is not in progress now.

@AndrewBastin
Copy link
Member

Hi @ashiishme, @KaviiSuri reached out to me a while back saying he is working on this.

@KaviiSuri please confirm you are working on it

@KaviiSuri
Copy link

Yeah I'm working on this, will send a PR soon

@liyasthomas liyasthomas changed the title Connecting to a very high traffic websocket server stalls [bug]: Connecting to a very high traffic websocket server stalls Oct 2, 2022
@ganudoomer
Copy link

ganudoomer commented Jun 23, 2023

Is this still up for grabs ? @KaviiSuri @AndrewBastin

@AndrewBastin
Copy link
Member

@ganudoomer yes you can pick this up if you want.

@varunagarwal007
Copy link

Hey @AndrewBastin, would like to work on it

@varunagarwal007
Copy link

@Gunni, have found the issue, let me know if it is still open to work

@Gunni
Copy link
Author

Gunni commented Sep 25, 2023

@Gunni, have found the issue, let me know if it is still open to work

afaik nobody has solved this, but it's been a long time.

@kpguru20001
Copy link
Contributor

Hi,
I ran the steps to reproduce but I am unable to reproduce the issue. I ended up fixing the Regex code to allow this particular type of URL
Here is a loom video: Loom Link

I was planning to update the regex to allow that particular syntax of wss urls

function generateREForProtocol(protocol) {
  return [
    new RegExp(
      `${protocol}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(:[0-9]+)?(\\/[^?#]*)?(\\?[^#]*)?(#.*)?$`
    ),
    new RegExp(
      `${protocol}(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])(:[0-9]+)?(\\/[^?#]*)?(\\?[^#]*)?(#.*)?$`
    ),
  ]
}

Please Guide me on how I can replicate this issue?

@Gunni
Copy link
Author

Gunni commented Oct 20, 2023

I ran the steps to reproduce but I am unable to reproduce the issue. I ended up fixing the Regex code to allow this particular type of URL

Thanks for fixing the parsing!

I am unable to reproduce the freezing issue too! Good?

@kpguru20001
Copy link
Contributor

Great, Then I ll create a PR for the parsing?

@shreyash010
Copy link

is this issue resolved?
I am getting all the logs from the socket connection.

I am new to open source and have also been working on MEVN stack if you can suggest me how to get started it will be of great help to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

10 participants