Skungee / Skungee-2.0.0

Remake of the Skungee system (TCP), to be using Japson a QUIC/UDP protocol.
https://forums.skunity.com/resources/skungee.87/
Apache License 2.0
46 stars 8 forks source link

API help, receiver not connecting #157

Open ks-hl opened 2 years ago

ks-hl commented 2 years ago

What you need help with

I'm trying to write a plugin to interface with the API which is capable of sending messages from proxy to server, server to proxy, and server to server. Server to proxy works flawlessly. However, trying to send messages from server to proxy or server to server is hit or miss. I'm not using the API examples exactly because they didn't work for me, so I may have something wrong in my code.

What you've tried so far

Everything works in my test environment. However, once I go to production, only 2 of the 5 spigot servers seem to be establishing their receivers with the proxy. Iterating BungeeSkungee#getServer() only gives the 2 of 5. Executing BungeeSkungee#getServer(String) for the 3 other servers throws NoSuchElementException. All servers are capable of communicating to the proxy, even the ones without a receiver connection. There are no errors, ports are assigned statically. I tried many different combinations of restarts, restarting in different orders, all at once, etc. The same 2 servers connect and the other 3 don't. Changing ports doesn't help.

Bungee Send

public void send(JapsonServer from, String msg, Set<SkungeeServer> servers)
            throws InterruptedException, ExecutionException, TimeoutException {
        JsonObject json = new JsonObject();
        json.addProperty("message", msg);
        for (SkungeeServer server : servers) {
            print("sending to " + server.getName());
            server.getServerData().setReceiverAddress(
                    new InetSocketAddress("127.0.0.1", server.getServerData().getReceiverAddress().getPort()));
            from.sendPacket(server.getServerData().getReceiverAddress(), new Packet(Packets.API.getPacketId()) {
                @Override
                public JsonObject toJson() {
                    return json;
                }
            });
        }
    }

Bungee Receive

ProxySkungee.getPlatform().getJapsonServer().registerHandlers(new Executor(Packets.API.getPacketId()) {
            @Override
            public void execute(InetSocketAddress address, JsonObject object) {
                if (!object.has("message"))
                    return;
                String message = object.get("message").getAsString();
                print("Message: " + message);
            }
        });
    }

Spigot Send

public void send(String msg) throws InterruptedException, ExecutionException, TimeoutException {
        JsonObject json = new JsonObject();
        json.addProperty("message", msg);
        skungeeAPI.sendJson(json);
    }

Spigot Receive

skungee.getReceiver().get().registerHandlers(new Executor(Packets.API.getPacketId()) {
            @Override
            public void execute(InetSocketAddress address, JsonObject object) {
                if (!object.has("message"))
                    return;
                String message = object.get("message").getAsString();
                print("Message: " + message);
            }
        });

Specifications

Skungee Version: 2.0.0-BETA-4 Proxy Platform and Version: This server is running Waterfall version git:Waterfall-Bootstrap:1.19-R0.1-SNAPSHOT:5c1e956:504 by md_5 System/Panel (if applicable): Debian

ks-hl commented 2 years ago

Thought I fixed it but I did not. I'm still getting mixed results with servers wanting to connect their receiver to the proxy. All servers can send to the proxy but the proxy can only send to half.