lucko / bytesocks

Fast & lightweight WebSocket server with channels.
MIT License
21 stars 3 forks source link

LuckPerms plugin cannot establish socket connection #1

Open SAVsciense opened 1 year ago

SAVsciense commented 1 year ago

Hi, I'm trying to make a selhosted luckpermsWeb. I raised a bytebin docker container and it works great The web editor is already working, but not in dynamic mode.

Server running in docker https://github.com/itzg/docker-minecraft-server

Server type - Spigot Server version - 1.19.2

I am trying to raise websockets in docker

docker-compose.yml:

version: "3.8"
services:
  bytesocks:
    image: ghcr.io/lucko/bytesocks
    ports:
      - 3001:8080
    environment:
      # You can configure bytesocks using
      # environment variables.
      BYTESOCKS_MISC_KEYLENGTH: 15
    extra_hosts:
      - "host.docker.internal:host-gateway"

But I am getting these errors

docker logs mc-server:

[01:24:19] [Server thread/INFO]: sav_miner issued server command: /lp editor
[01:24:19] [OkHttp https://host.docker.internal:3000/.../WARN]: [LuckPerms] Exception occurred in web socket
java.net.ProtocolException: Expected HTTP 101 response but was '404 Not Found'
    at me.lucko.luckperms.lib.okhttp3.internal.ws.RealWebSocket.checkUpgradeSuccess(RealWebSocket.java:224) ~[?:?]
    at me.lucko.luckperms.lib.okhttp3.internal.ws.RealWebSocket$1.onResponse(RealWebSocket.java:195) ~[?:?]
    at me.lucko.luckperms.lib.okhttp3.RealCall$AsyncCall.execute(RealCall.java:174) ~[?:?]
    at me.lucko.luckperms.lib.okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
    at java.lang.Thread.run(Unknown Source) ~[?:?]
[01:24:24] [luckperms-command-executor/WARN]: [LuckPerms] Unable to establish socket connection
java.lang.RuntimeException: Timed out waiting to socket to connect
    at me.lucko.luckperms.common.webeditor.socket.WebEditorSocket.waitForConnect(WebEditorSocket.java:103) ~[?:?]
    at me.lucko.luckperms.common.webeditor.WebEditorSession.createSocket(WebEditorSession.java:96) ~[?:?]
    at me.lucko.luckperms.common.webeditor.WebEditorSession.open(WebEditorSession.java:87) ~[?:?]
    at me.lucko.luckperms.common.webeditor.WebEditorSession.createAndOpen(WebEditorSession.java:62) ~[?:?]
    at me.lucko.luckperms.common.commands.misc.EditorCommand.execute(EditorCommand.java:111) ~[?:?]
    at me.lucko.luckperms.common.command.abstraction.SingleCommand.execute(SingleCommand.java:56) ~[?:?]
    at me.lucko.luckperms.common.command.abstraction.SingleCommand.execute(SingleCommand.java:48) ~[?:?]
    at me.lucko.luckperms.common.command.CommandManager.execute(CommandManager.java:265) ~[?:?]
    at me.lucko.luckperms.common.command.CommandManager.lambda$executeCommand$1(CommandManager.java:169) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
    at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.CompletableFuture.timedGet(Unknown Source) ~[?:?]
    at java.util.concurrent.CompletableFuture.get(Unknown Source) ~[?:?]
    at me.lucko.luckperms.common.webeditor.socket.WebEditorSocket.waitForConnect(WebEditorSocket.java:101) ~[?:?]
    ... 12 

This creates a channel

  [02:18:38 INFO]: [CREATE]
    channel id = JIVnBpcLwQ1n4pL
    user agent = curl/7.87.0
    ip = 192.168.192.1

I also have nginx configured. Because the plugin was throwing the sun.security.provider.certpath.SunCertPathBuilderException error. Therefore, I had to raise nginx to provide an https connection.

nginx.conf:

server {
         listen 443 ssl;

         ssl_certificate /certs/bytesocks/server.crt;
         ssl_certificate_key /certs/bytesocks/server.key;

         error_page 497 =301 https://$host:3000$request_uri;

         location / {
             client_max_body_size 30M;
             client_body_timeout 60s;

             proxy_set_header Host $host;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header X-Forwarded-Proto $scheme;
             proxy_redirect http:// https://;

             proxy_pass http://host.docker.internal:3001/;
         }
     }

I don't think that's the problem either. Because:

  1. curl localhost:3001 (direct port) and curl localhost:3000 return just a "/"
  2. curl -IL localhost:3001 (direct port) and curl https://localhost:3000 (https because nginx redirect) output is 404
  3. For both i can create channel curl localhost:*/create
  4. Can connect to socket websocat ws://host.docker.internal:*/<id>

Unfortunately, I have not found documentation for bytesocks anywhere. On the LuckPerms wiki under "Self hosting the web interfaces" also no mention of bytesocks

aaron2198 commented 1 year ago

I ran into something similar and the issue ended up being the mod configuration in the minecraft server. Checkout this issue I made explaining what was found https://github.com/lucko/spark-docs/issues/3, perhaps you just need to change the config key from bytesocksUrl to bytesocksHost (for now).

aaron2198 commented 1 year ago

I ran into something similar and the issue ended up being the mod configuration in the minecraft server. Checkout this issue I made explaining what was found lucko/spark-docs#3, perhaps you just need to change the config key from bytesocksUrl to bytesocksHost (for now).

I understand now that this is related to luckperms and not spark profiling, so maybe what I have mentioned here is not helpful.

TheJoshue commented 1 year ago

did you solve the issue in the end? @SAVsciense and can you explain what did you do

TheJoshue commented 1 year ago

i solved it, for me it works.