Return challenge field on subscription with Java (EventSub)

I’ve ended up finding the solution. As it’s manual, it requires more steps. The CLI and Twitch asks for a valid HTTP response, not a raw one. In raw means that at least the HTTP response has to be text/plain, but it still requires the entire structure, so probably the send method on your nodejs code also includes the required headers for a response. I still have to learn more about the HTTP standard to make manual sendings, but I could repair it with this headers:

writer.write("HTTP/1.0 200 OK\r\n"
+ "Content-type: text/plain; charset=UTF-8\r\n"
+ "Content-Length: " + challenge.length() + "\r\n\r\n"
+ challenge);