×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    55

    Unhappy Unable To Disconnect Http Connection

    Hi! I have difficulty in closing the Http connection. Actually I have close the connection after opening the connection in my module but if the user wanted to exit the application, I'll check if the connection != null, I'll close the connection again. The problem is if the new Http connection is not yet established while calling the Http module and the user exit the application, it won't be able to close the http connection. How to solve this issue? I have checked through the forum and is unable to find a solution. Please advise. Thanks in advance!



    Jac

  2. #2
    Registered User
    Join Date
    Oct 2005
    Posts
    16

    Re: Unable To Disconnect Http Connection

    It probably depends on your device but..
    You will have to close inputStreams and outputStreams that you got off the connection. If that is not enough to stop the connection, you could interrupt the the thread doing the Http Request.
    Worked for me on a Series 60 device. I needed to implement a timeout.

  3. #3
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    307

    Re: Unable To Disconnect Http Connection

    Have you tried to use "finally" blocks?

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    55

    Re: Unable To Disconnect Http Connection

    Yup. I put the finally blocks to check if the connection != null, I'll close the connection by issuing connection.close(). Before closing the connection, I'll also determine the DataInputStream and OutputStream and close it first. Testing using the emulator won't be a problem except my real device (Nokia Communicator). In order to check the http connection is ok, I tried out the browser and it will automatically not showing the Wifi icon after closing the browser application.

    After the 'unclosed' http connection, I'm unable to start my application again and the whole event look like the device is 'hang'.

    If anyone having the same issue like me, please give me some advice upon this issue.


    Thanks in advance!

  5. #5
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    307

    Re: Unable To Disconnect Http Connection

    Just one more thing. If you will go on S40 mobile phone to the Settings -> Connectivity -> GPRS -> GPRS Connection, you should see two options: "When needed" and "Always online". Check out which option is activated on your phone. Maybe this will help you.

  6. #6
    Registered User
    Join Date
    Oct 2005
    Posts
    55

    Re: Unable To Disconnect Http Connection

    My device is Nokia Communicator. I have set to ask for permission whenever I want to make a connection. Just wonder why sometimes the connection will not be closed successfully. I'm not sure about other Nokia device buy my current device will auto add the Exit button onto my application and if I triggered the Exit button, it won't close successfully. is there any way to disable the button. As I know it can't be done.

  7. #7
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Talking Re: Unable To Disconnect Http Connection

    Hi Jaceline! If you want to delete that "automatic" Exit buttom that appears in your application, you only have to add to your Screen object (Form, List... that object you are using to paint the data in the display) a new Command object with the Command.EXIT type attribute in its constructor!
    Please, I advise you to see the Command Class in the javax.microedition.lcdui packet inside the MIDP 2.0 API: http://www.j2medev.com/api/midp/java...i/Command.html )

    Once you have made it, you only have to do those operations which you want in the CommandAction() method! In this case, kill all your running Threads and close all your running communications!

    I understand you when you told me that your application is freezing! It's because your thread that manages the HTTP communication is alive, even if the MIDlet is closed, and it is doing its job!

    I expect to solve your problems!

  8. #8
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Unable To Disconnect Http Connection

    hi jaceline,

    "Exit" added by system should be probably trapped in destroyApp(....) method,
    it has unconditional == true at least on S60 platform,
    http://discussion.forum.nokia.com/fo...51&postcount=4
    that system command is not trappable by commandAction at all - again - at least on S60 platform prior to 3rd edition
    what I posted is based on kb technote by FN:
    You cannot remove the Close/Exit command from the left softkey. The Close command is automatically added by the Symbian OS, and therefore it cannot be altered by the Java implementation. This is the situation in all S60 (and Series 80) devices.
    http://forum.nokia.com/Technical_Lib...Nokia_6600.htm

    hth,
    regards,
    Peter

  9. #9
    Registered User
    Join Date
    Oct 2005
    Posts
    55

    Re: Unable To Disconnect Http Connection

    Thanks for your replies. I have checked through the websites from you guys. My application is creating a new list control and added the new commands onto it. I have set focus on the command buttons which I have created including my own Command.Exit. Although I have created new command buttons, the existing Exit button is still there

Similar Threads

  1. Replies: 2
    Last Post: 2006-10-06, 17:24
  2. Http Connection
    By jaceline in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2006-06-09, 16:53
  3. Close HTTp Connection in N6230i
    By cars2004 in forum Mobile Java General
    Replies: 1
    Last Post: 2005-06-24, 10:46
  4. Unable to make http connection with Nokia 3530
    By corej2me in forum Mobile Java General
    Replies: 1
    Last Post: 2004-09-06, 10:51
  5. HTTP connection on 6310i, 7650, 9210 and in sony-ericsson p800
    By mika1982 in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2003-07-24, 16:44

Posting Permissions

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