Java - Connecting to Node.JS Websocket Server

I’m currently using Render to host a small Websocket server for my Java Minecraft Client. The server is up and running no errors, but when I try to connect to it within my client I get multiple errors. This is the connection code (Java):
try {
WebSocketFactory wsFactory = new WebSocketFactory();
SSLContextBuilder contextBuilder = new SSLContextBuilder();
contextBuilder.useTLS();
SSLContext context = contextBuilder.build();
wsFactory.setSSLContext(context);
//wsFactory.setVerifyHostname(false);
// create the websocket
ws = wsFactory.createSocket(“uri-goes-here”);
ws.setPingInterval(30);
Hyper.LOGGER.info(“Connecting to the server…”);
} catch (IOException e) {
Hyper.LOGGER.error(“Failed to create WebSocketFactory!”);
e.printStackTrace();
} catch (NoSuchAlgorithmException | KeyManagementException e) {
throw new RuntimeException(e);
}

  • some more things that are not important.
    Please note that before moving to Render I was using Heroku and it worked perfectly with the same code. “The certificate of the peer does not match the expected hostname” is the error that I got first. I then read online that I could use wsFactory.setVerifyHostname(false); as a work around for the first error. I tried that as well and I got a fatal_handshake error when connecting. As a websocket library I’m currently using com.neovisionaries.ws.client.

I’m pretty sure this isn’t an issue with my way of connecting because as I said this used to work just fine when I used Heroku, but now it won’t let me connect. I tried a bunch more things like changing the TLS to SSL or to TLSv1.2 v1.1 yet nothing seems to work.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.