0

I have written a J2ME application using WTK 2.5.2 with JDK 1.8.0_361 and JDK 1.5.0_22.

The following code snippet is used to connect to an HTTP server and it works as expected.

try{
    http = (HttpConnection)Connector.open(url);
    http.setRequestMethod(HttpConnection.POST);

    OutputStream os = http.openOutputStream();

    String params = "XXXXXXXX";
    os.write(params.getBytes());
        
    respCode = http.getResponseCode();
}catch(Exception e){
    System.out.println(e);
}

However, when trying to connect to an HTTPS site, it throws one of these two errors:

Google:

java.io.IOException: Bad record type (21) or version (3.1)
    at com.sun.midp.ssl.Record.rdRec(+284)
    at com.sun.midp.ssl.Record.rdRec(+5)
    at com.sun.midp.ssl.Handshake.getNextMsg(+17)
    at com.sun.midp.ssl.Handshake.rcvSrvrHello(+5)
    at com.sun.midp.ssl.Handshake.doHandShake(+29)
    at com.sun.midp.ssl.SSLStreamConnection.<init>(+173)
    at com.sun.midp.ssl.SSLStreamConnection.<init>(+12)
    at com.sun.midp.io.j2me.https.Protocol.connect(+214)
    at com.sun.midp.io.j2me.http.Protocol.streamConnect(+57)
    at com.sun.midp.io.j2me.http.Protocol.startRequest(+12)
    at com.sun.midp.io.j2me.http.Protocol.sendRequest(+38)
    at com.sun.midp.io.j2me.http.Protocol.sendRequest(+6)
    at com.sun.midp.io.j2me.http.Protocol.getResponseCode(+8)
    at whatsapp.WhatsAppClass.startApp(+34)
    at javax.microedition.midlet.MIDletProxy.startApp(+7)
    at com.sun.midp.midlet.Scheduler.schedule(+270)
    at com.sun.midp.main.Main.runLocalClass(+28)
    at com.sun.midp.main.Main.main(+80)

Wikipedia:

java.io.IOException: Alert (2,40)
    at com.sun.midp.ssl.Record.rdRec(+228)
    at com.sun.midp.ssl.Handshake.getNextMsg(+17)
    at com.sun.midp.ssl.Handshake.rcvSrvrHello(+5)
    at com.sun.midp.ssl.Handshake.doHandShake(+29)
    at com.sun.midp.ssl.SSLStreamConnection.<init>(+173)
    at com.sun.midp.ssl.SSLStreamConnection.<init>(+12)
    at com.sun.midp.io.j2me.https.Protocol.connect(+214)
    at com.sun.midp.io.j2me.http.Protocol.streamConnect(+57)
    at com.sun.midp.io.j2me.http.Protocol.startRequest(+12)
    at com.sun.midp.io.j2me.http.Protocol.sendRequest(+38)
    at com.sun.midp.io.j2me.http.Protocol.sendRequest(+6)
    at com.sun.midp.io.j2me.http.Protocol.getResponseCode(+8)
    at whatsapp.WhatsAppClass.startApp(+34)
    at javax.microedition.midlet.MIDletProxy.startApp(+7)
    at com.sun.midp.midlet.Scheduler.schedule(+270)
    at com.sun.midp.main.Main.runLocalClass(+28)
    at com.sun.midp.main.Main.main(+80)

I have tried using HttpsConnection and switching to another WTK and JRE version.

Exporting the application to device shows another error:

java.io.IOException: Alert (2, 70)

Thanks in advance.

kelkeke
  • 1
  • 1

0 Answers0