1

This is where I got the socketIO files from. https://github.com/Gottox/socket.io-java-client/tree/master/src/io/socket

I am on the client side. I know connecting works when the server does not need authentication.

But when it needs authentication (Username and password), I get a handshaking error message.

How do I get passed authentication?? Could it be a server side error? Would the server side of things change if authentication was added?

This is the function that throws an error...I did not write it. This line is the one causing problems: InputStream stream = connection.getInputStream(); It says it is caused by: java.io.FileNotFoundException: url:80/socket.io/1/

private void handshake() {
    URL url;
    String response;
    URLConnection connection;
    try {
        setState(STATE_HANDSHAKE);
        url = new URL(IOConnection.this.url.toString() + SOCKET_IO_1);
        connection = url.openConnection();
        if (connection instanceof HttpsURLConnection) {
            ((HttpsURLConnection) connection)
                    .setSSLSocketFactory(sslContext.getSocketFactory());
        }
        connection.setConnectTimeout(connectTimeout);
        connection.setReadTimeout(connectTimeout);

        /* Setting the request headers */
        for (Entry<Object, Object> entry : headers.entrySet()) {
            connection.setRequestProperty((String) entry.getKey(),
                    (String) entry.getValue());
        }

        InputStream stream = connection.getInputStream();
        Scanner in = new Scanner(stream);
        response = in.nextLine();
        String[] data = response.split(":");
        sessionId = data[0];
        heartbeatTimeout = Long.parseLong(data[1]) * 1000;
        closingTimeout = Long.parseLong(data[2]) * 1000;
        protocols = Arrays.asList(data[3].split(","));
    } catch (Exception e) {
        error(new SocketIOException("Error while handshaking", e));
    }
}
Andre Viau
  • 275
  • 2
  • 5
  • 17

1 Answers1

0

Problem solved (sort of), here: Android developpement, Gottox socket.io-java-client: file not fount Exception /socket.io/1/

(try using an earlier version of socket.io - by first deleting socket.io folder from node_modules and then install an older version, e.g., 0.9.16, using this command: npm install socket.io@0.9.16)

Community
  • 1
  • 1
Larky
  • 126
  • 1