Good afternoon to everyone,
Sorry if this is already something answered, but after googling, I didn’t find anything similar to this issue. I’m new with EventSub, and I’ve been this days fighting to prepare it so my Java client can create a ServerSocket with SSL using LetsEncrypt, but the issue comes when I try to return the challenge.
On the EventSub documentation, says that once I get the verification as a POST request using the ServerSocket, and I got that, also the challenge. After getting it, says that I have to return it as a raw value. I checked the challenge, and didn’t seem to be a text that should require an encoding, but I used that in case:
String challenge = URLEncoder.encode(element.asObject().getObject("challenge").asData().getAsString(), "UTF-8");
The problem is that I can’t seem to find a way to send it back, in a way that Twitch returns me another answer than the same verification. I saw that it should give you like a ‘failed’ answer in case you didn’t give a correct answer, but it keeps returning me the ‘pending’ state. This is my actual way to send it back to Twitch in Java:
String challenge = URLEncoder.encode(element.asObject().getObject("challenge").asData().getAsString(), "UTF-8"); System.out.println(challenge); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(event.getSocket().getOutputStream())); writer.write(challenge); writer.flush(); writer.close();
Just wondering if I should add something else like headers or something, or if I should instance another kind of connection like URLConnection or anything else than Socket. The only answers I saw on other posts is that it should be a return made on the same connection, cause this I’m using the same Socket, also as I searched inside the BarryCarlyon’s code for nodejs, where uses the reponse given in the callback to answer only with the challenge using ‘res.send(encodeURIComponent(req.body.challenge))’, but I don’t know if Express creates a new connection instead of using the same one.