×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    23

    Problem with httplib.HTTPConnection

    Hi everyone,
    I hope someone can help me! I'm working on some N95 running Python for S60 1.4.1. Untill now the same code has worked. The accused code is the following:
    Code:
    import httplib, urllib
    import socket
    
    apid = socket.select_access_point()
    apo = socket.access_point(apid)
    socket.set_default_access_point(apo)
    
    diz = {'par1' : 1000, 'par2':2000, 'par3':3000}
    params = urllib.urlencode(diz)
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("xxx.xxx.xxx.xxx")
    conn.request("POST", "/script.php", params, headers) 
    response = conn.getresponse()
    var = response.read()
    conn.close()
    The problem is quite strange! Untill yesterday this code doesn't have given me any problem. From yesterday, it sometimes works, the other times I got (at the bold line) one of the following problems:


    File "c:\resource\httplib.py", line 627, in connect
    return SSLFile(self._shared, self._ssl, bufsize)
    error: (56, 'Connection timed out')

    File "c:\resource\socket.py", line 58, in socket
    return _socketobject(_realsocketcall(family, type, proto, apo), family)
    RuntimeError: Couldn't start RConnection

    File "c:\resource\httplib.py", line 627, in connect
    return SSLFile(self._shared, self._ssl, bufsize)
    error: (0, 'Error')


    I thought "maybe it was me, Maybe I have changed something without wanting in the code" BUT I tried also with some backup version of the code (that I know for sure that was working) and it's the same!!!
    I tried with both WLAN and Packet data connection but nothing!

    Thanks a lot
    Chiara

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Problem with httplib.HTTPConnection

    Quote Originally Posted by Chiara81000 View Post
    it sometimes works, the other times ... problems
    Reboot your phone, start python and run your script. Does it work?

    If it does, script should be ok. The problem would be caused by the environment: what other apps are running at the same time, are they using network connection, how good network connection you have (signal strenght) etc.

    Solution possibilities... Well, go back as far as you can until it works ALL THE TIME. Have you added something which effects timing, like second thread, timers, active objects etc.

    Just generic network connection debugging, hope you'll find out a solution.

    Cheers,

    --jouni

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    23

    Re: Problem with httplib.HTTPConnection

    HI JOM!!! Thanks a lot for the fast and complete answer!

    Quote Originally Posted by JOM View Post
    Reboot your phone, start python and run your script. Does it work?
    Yes, it does! It has given me the answer immediately and I couldn't believe it because I had already tried to reboot the phone and to change Sim.

    Quote Originally Posted by JOM View Post
    If it does, script should be ok.
    I'm happy of this!

    Quote Originally Posted by JOM View Post
    The problem would be caused by the environment: what other apps are running at the same time, are they using network connection, how good network connection you have (signal strenght) etc.
    I was thinking the same...but at least the WLAN connection should have been good! I have a bad news... it started to give exactly the same errors.

    Do you think that there could be any other problem? Can I ask you to check this post? What do you think about it?
    He got my same error "RConnection" ... I'd want to be sure that is only fault of the environment!

    http://discussion.forum.nokia.com/fo...ht=RConnection

    Thanks a lot again
    Chiara
    Last edited by Chiara81000; 2008-05-20 at 21:38.

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Problem with httplib.HTTPConnection

    Quote Originally Posted by Chiara81000 View Post
    the WLAN connection should have been good! I have a bad news... it started to give exactly the same errors.
    First it works ok and then after a while it starts failing == something is getting slowly corrupted. Are you reserving more and more resources, never releasing them? Do you just create new connections and never close them? Python does have automatic memory & resource management, but sometimes it needs a little bit of help.

    Quote Originally Posted by Chiara81000 View Post
    Can I ask you to check this post? What do you think about it? He got my same error "RConnection" ... I'd want to be sure that is only fault of the environment!

    http://discussion.forum.nokia.com/fo...ht=RConnection
    Heh, easy to check: miohtama is a guru, listen very carefully whatever he says and follow the instructions to the point

    Maybe you could run your code through pylint just in case? I don't think it would find memory / resource leaks, but who knows. I've coded several years in several languages in several operating systems and 99% problem cases have been in my own code, or could be fixed in my code, instead of being "system defects". I've seen some, even hardware defects, but don't really believe in them.

    Last night I spend over two hours debugging mysterious crash, which most likely was caused by reading array out-of-bounds. I added an extra buffer at the end and now everything works. The original code was supposed to be ok. I verified indexing a hundred times and then again. No idea what happened, never managed to get a usable traceback..

    Very tired,

    --jouni

Similar Threads

  1. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  2. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  3. WAP service problem on Apache
    By bigg_o in forum Browsing and Mark-ups
    Replies: 3
    Last Post: 2005-04-17, 16:05
  4. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

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