Hey all! I have tried, tried, and tried again to get POST requests working in PowerNukkitX, but for some reason it just won't work.
Basically, every time a player joins I'm trying to send over a POST request to my server to store basic information about the player (statistical purposes and whatnot). The API works on its own (RestTestTest can go through it fine with no issue), and the event handler registers correctly, but the actual call to send a POST request always returns the same error:
00:25:58 [ForkJoinPool.commonPool-worker-1] [WARN] [CapeManager]: Failed to send HTTP request: (handshake_failure) Received fatal alert: handshake_failure
WHAT I HAVE TRIED DOING:
- Attempted multiple domains-- both my own and GitHub fail to handshake, meaning they don't even get something like a 404 error code and quit after failing to establish an HTTPS connection
- Altering all sorts of HttpClient settings, from the ciphers available to TLS version and everything inbetween
- Over an hour of troubleshooting with various A.I. agents (ChatGPT, Grok) none of which were any help
- Setting CORS and other networking options on my server to increasingly low levels of security (but cannot disable HTTPS)
- Bashing my head against a wall (still did nothing)
Project Java Version: 24
MY WORKING FUNCTION CODE:```java
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
String capeId = player.getSkin().getCapeId();
capeManager.getLogger().info("Player " + player.getLoginChainData().getXUID() + " joined with Cape ID " + capeId);
String url = "https://website.lol/log-user";
HttpClient client = HttpClient.newHttpClient();
String body = "{\"xuid\": \"" + player.getLoginChainData().getXUID() + "\", \"username\": \"" + player.getName() + "\", \"capeId\": \"" + capeId + "\"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Authorization", "mypasswordhere")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
CompletableFuture.runAsync(() -> {
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
capeManager.getLogger().info("Request to " + url + " was successful!");
} else {
capeManager.getLogger().warning("Request to " + url + " failed with status code: " + response.statusCode());
}
System.out.println("Status Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
} catch (IOException | InterruptedException e) {
capeManager.getLogger().warning("Failed to send HTTP request: " + e.getMessage());
}
});
}```
The requests work fine in a standalone Java project, for some reason this is exclusively limited to when it's run as a plugin within my test server. I have spent hours upon hours trying to fix this, and this server is truly my last hope. If anybody can help me fix this, please let me know!
Thank you!