×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    9

    Smile http connection in J2me(working fine in emulator but not in real device)???

    hi gus,
    I have developed application which uses HttPConnection GET method to connection to server....where server listen to the port 3000...

    its working fine in emulator but in real device its throwing IOException... server doest not get any message from mobile clinet......

    I got error timed out error messge(Error number -33)

    I check with GPRS connection... it working fine and it can pull google search page.....

    I user the server address in mobile browser... server can receive request...

    Is there any thing else i need to check....

    and in some device it says "IOException:could not read from the socket"
    I created textfield and and print responce code.... it coming with OK and also prints the data which I expect from server....


    my code::
    ========
    httpconn = (HttpConnection) Connector.open("http://202.87.41.193:3000"+"?"+"welcome);

    httpconn.setRequestMethod(HttpConnection.GET);
    int response=httpconn.getResponseCode();
    if(response == HttpConnection.HTTP_OK )
    {
    os= httpconn.openOutputStream();
    is = httpconn.openInputStream();
    int ch;

    while ((ch = is.read()) != -1) //reading data from server
    b.append((char) ch);
    }


    server code
    =========

    public class httpserver {
    int listenPort;
    public httpserver(int aListenPort) {
    listenPort = aListenPort;
    }
    public void acceptConnections() {
    try {
    ServerSocket server = new ServerSocket(listenPort);
    Socket incomingConnection = null;
    while (true) {
    System.out.println("waiting");
    incomingConnection = server.accept();
    handleConnection(incomingConnection);
    }
    } catch (BindException e) {
    System.out.println("Unable to bind to port " + listenPort);
    } catch (IOException e) {
    System.out.println("Unable to instantiate a ServerSocket on port: " + listenPort);
    }
    }

    public void handleConnection(Socket incomingConnection) {
    System.out.println("handling connection..");
    try{
    StringBuffer sb1 = new StringBuffer();
    OutputStream outputToSocket = incomingConnection.getOutputStream();
    PrintWriter streamWriter = new PrintWriter(incomingConnection.getOutputStream());
    streamWriter.println("HTTP/1.0 200 OK");
    streamWriter.println("Content-Type: text/html\n");
    streamWriter.println("done");
    streamWriter.flush();
    }catch(IOException ie){
    System.out.println(ie);
    } catch (Exception e) {
    System.out.println("Error handling a client: " + e);
    }
    }

    public static void main(String[] args) {
    httpserver server = new httpserver(3000);
    server.acceptConnections();
    }
    }


    plz help me to find solution..........

    thanks in adance
    R.Prasad

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: http connection in J2me(working fine in emulator but not in real device)???

    You do not mention which phone you are using. If you are using Series 40 phone, you need to define the preferred access point beore MIDlets are able to connect to network
    see for example
    http://blogs.forum.nokia.com/view_entry.html?id=282

    Hartti

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    9

    Re: http connection in J2me(working fine in emulator but not in real device)???

    I tryed in Nokia 3250..its working fine....requestis going to server and moblie can read data from server.... if I use Nokia 6600.. it give IOException:unexpected end of stream....

    it throwing error exactly in line is = httpconn.openInputStream();

    I tryed in Nokia 6680 it give same error message....

    I hope problem lies in opening inputStream......

    what character should be stream ????

    I am using the same code which is give above...

    plz find me solution....

    thanks in advance
    R.Prasad

Similar Threads

  1. Device IOException:HTTP-Version Mismatch with nokia 7650 real
    By imendez6 in forum Mobile Java General
    Replies: 6
    Last Post: 2012-01-13, 17:23
  2. http connection via a proxy programmatically
    By tiansun in forum Mobile Java General
    Replies: 0
    Last Post: 2005-04-19, 02:47
  3. problem http connection in real device
    By debasish1234 in forum Symbian
    Replies: 2
    Last Post: 2005-01-31, 14:38
  4. my http connection works on series60,doesn't on series 40
    By silvolu in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2003-04-23, 22:00
  5. Device IOException:HTTP-Version Mismatch with nokia 7650 real
    By imendez6 in forum Mobile Java General
    Replies: 1
    Last Post: 2002-10-04, 20:58

Posting Permissions

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