×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    27

    Question HTTPS Error "Wrong State: 5"

    Hi all, I'm having an error trying to communicate my j2me app with a php server using https, now the thing is.. It's the first time I ever use https.. So I coud be missing something a bit obvious to many of the programmers around here... So please, Help me out as you can..

    This is the important part of the code (I don't wanna paste the whole code to avoid extra lines):

    Code:
    //Starts the Try block
    try {
    //Https declaration and initialization, as well as certificate information I want to acquire and see...
                HttpsConnection https = (HttpsConnection) Connector.open(url_base);
                SecurityInfo si = https.getSecurityInfo();
                Certificate c = si.getServerCertificate();
                String subject = c.getSubject();
    
    //Setting POST Method and ContentType as well as USer-Agent..
                https.setRequestMethod(HttpsConnection.POST);
                https.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                https.setRequestProperty("User-Agent", "HttpMidlet/0.2");
    
    //Vars for Data and InputStream
                byte[] data = null;
                InputStream istrm = null;
    
    //Length of Outgoing data
                https.setRequestProperty("Content-length", "" + content.getBytes().length);
    
    //Streaming (OUT)
                OutputStream out = https.openOutputStream();
    
    . . . . .
    From now on the code is useless since I can't get further than this... I keep getting an error starting the Try block just after getting info on the Certificate (I actually can print the info on the certificate so it finds the server)... then I go to the Catch section... Throwing this:

    Code:
    Exception: "wrong state: 5"
    I want to point out that I'm using Xampp with a just-created certificate (using xampp's certificate creator), the App connects to my wireless network and tries to access the server via IP, and it does since I can see the certification information from the server on my cel using a custom "output console" on my cel...

    What do you guys think? I'm trying to send simple info between both peers, Client(j2me) and Server (PC - xampp (php) )

    Thanks in advance even if you can't help, anything that might ease this for me will be much appreciated,

    Armando Leon
    Last edited by lparmy; 2010-08-30 at 07:40. Reason: misspelledwords

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: HTTPS Error "Wrong State: 5"

    try commenting out these:

    //Certificate c = si.getServerCertificate();
    // String subject = c.getSubject();
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    27

    Re: HTTPS Error "Wrong State: 5"

    Quote Originally Posted by im2amit View Post
    try commenting out these:

    //Certificate c = si.getServerCertificate();
    // String subject = c.getSubject();
    On it! brb :P

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    27

    Re: HTTPS Error "Wrong State: 5"

    Quote Originally Posted by im2amit View Post
    try commenting out these:

    //Certificate c = si.getServerCertificate();
    // String subject = c.getSubject();
    Same error :/

  5. #5
    Registered User
    Join Date
    Nov 2009
    Posts
    27

    Re: HTTPS Error "Wrong State: 5"

    I checked the packets through the Network between both peers (client and server) And I noticed that all the packets sent from the server had a flag of incorrect Header Checksum, I don't if that's a coincidence or is a signal of something going wrong with my php server. I've Tried accessing the php server via https from my cellphones browser and it seems to work just fine, So I don't know I feel like a little lost on specifying which of those (client or server) is responsible for the wrong communication.... :/

    Armando Leon

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    27

    Re: HTTPS Error "Wrong State: 5"

    Btw I just noticed that I'm focusing in the eror the wrong way, That "wrong state: 5" error is referred to the IOException, so I'll start looking for it..

  7. #7
    Registered User
    Join Date
    Nov 2009
    Posts
    27

    Re: HTTPS Error "Wrong State: 5"

    I commented all the certificate lines on the code just as you suggested last night (I think I didn't transfer the .jar correctly, My bad) Now I'm getting an HTTP Error (301 - Moved Permanently)

  8. #8
    Registered User
    Join Date
    Nov 2009
    Posts
    27

    Re: HTTPS Error "Wrong State: 5"

    I fixed that status code. Was pointing to "some/directory/" and it threw the right address "some/directory/index.php".. Changed that in the code and everything is fine now... Thanks for the help... Really appreciated.

    I would close this thread. Don't know if I can do it personally or must be a Forum Admin...
    Last edited by lparmy; 2010-08-31 at 03:02. Reason: This thread should be closed now.

  9. #9
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: HTTPS Error "Wrong State: 5"

    It good to see that my advise helped you... thou you were required to try hard.

    Keep the hard work going, best of luck.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

Similar Threads

  1. WML - Error "Operation failed" / "your application is too large"
    By crajesh_2985 in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2009-10-06, 12:31
  2. Replies: 1
    Last Post: 2009-06-03, 12:43
  3. Replies: 4
    Last Post: 2008-05-20, 19:07
  4. can v get sender number/address when new entry of SMS is in "preparing" state?
    By nakummitul in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-07-28, 20:38
  5. Replies: 0
    Last Post: 2005-02-16, 14:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×