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

API help, receiver not connecting #157

Open
ks-hl opened this issue Oct 3, 2022 · 1 comment
Open

API help, receiver not connecting #157

ks-hl opened this issue Oct 3, 2022 · 1 comment
Labels
support question User needs help with installation

Comments

@ks-hl
Copy link

ks-hl commented Oct 3, 2022

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 ks-hl added the support question User needs help with installation label Oct 3, 2022
@ks-hl ks-hl closed this as completed Oct 3, 2022
@ks-hl ks-hl reopened this Oct 4, 2022
@ks-hl
Copy link
Author

ks-hl commented Oct 4, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support question User needs help with installation
Projects
None yet
Development

No branches or pull requests

1 participant