CraftsBlock / CraftsNet

Easy creation of HTTP routes and WebSocket endpoints in Java.
Apache License 2.0
7 stars 0 forks source link

Craftsnet using 100% CPU constantly #2

Closed pauljako closed 2 weeks ago

pauljako commented 3 weeks ago

Describe the bug When running my Cosmetic Server, CrafstNet is using 100% of CPU usage. And other containers on my VPS get slow

To Reproduce Steps to reproduce the behavior:

  1. Deploy the following Docker Image: pauljako/airserver (Build from pauljako/airserver)
  2. Open htop
  3. The Craftsnet Java Process is using 100% of the CPU

Expected behavior Only the CPU power that is needed should be used

Version

CrAfTsArMy commented 3 weeks ago

Hey, does this bug appear immediately after starting, or does it take time to appear? I have tested your docker image on my machine and it only uses about 0.09% of my CPU.

pauljako commented 3 weeks ago

Odd... for me it happens directly after starting

CrAfTsArMy commented 3 weeks ago

Can you try to update your CraftsNet version to 3.3.1-SNAPSHOT?

pauljako commented 3 weeks ago

Screenshot

pauljako commented 3 weeks ago

Can you try to update your CraftsNet version to 3.3.1-SNAPSHOT?

The Issue is still there

CrAfTsArMy commented 3 weeks ago

Is a client connected or does this also occur without a client connection?

pauljako commented 3 weeks ago

There is no Client connected right now

CrAfTsArMy commented 3 weeks ago

Can you show me a screenshot of htop in the tree view (toggle with F5)

pauljako commented 3 weeks ago

Image

CrAfTsArMy commented 3 weeks ago

Does this also occur if you do not load your addon? (You can disable the addon system with --disableAddonSystem or just remove the addon jar)

CrAfTsArMy commented 3 weeks ago

I forgot that if you deactivate the addon, you have to append --forceWebSocketServer --forceWebServer so that the servers are still started.

CrAfTsArMy commented 3 weeks ago

I have a possible solution for your issue. Please try upgrading to the experimental version 3.3.1-pre3 which should fix your issue. If you want to use experimental versions of CraftsNet you have to add the repo maven { url "https://repo.craftsblock.de/experimental" } (this is the notation for the gradle dsl) to your repositories.

You can find a runnable version of the jar at https://repo.craftsblock.de/#/experimental.

pauljako commented 3 weeks ago

Unfortunately, this doesn't change anything. But I did some testing and found out that this issue appears to be docker-compose related? Executing docker run --rm -it pauljako/airserver does not cause this issue

Here's my compose file:

services:
  airserver:
    container_name: airserver
    restart: unless-stopped
    ports:
      - 3400:5000
      - 3401:5001
    image: pauljako/airserver
    volumes:
      - ./airserver-data:/data/addons/AirServer
CrAfTsArMy commented 3 weeks ago

Strange, that's probably why I didn't have this bug, because I had tested it via docker. I'll definitely take a closer look at this again with docker-compose. Until then, I would recommend running it via a normal docker container.

CrAfTsArMy commented 3 weeks ago

I was able to reproduce the bug using docker compose and found the error after some research. The problem occurred in the console reader, which somehow went crazy when executed by docker compose and looped every millisecond.

You can update to 3.3.1-pre4 so that you can use docker compose again until the next latest version comes out. (You will still need the experimental repo from craftsblock for this.) You can download a runnable jar for CraftsNet here (https://cloud.craftsblock.de/s/craftsnet/download/CraftsNet.jar). (You can also use the link in your Dockerfile).

CrAfTsArMy commented 2 weeks ago

@pauljako has this fix solved the issue for you?

pauljako commented 2 weeks ago

Yes this fixed it. Thank you very much