×

Discussion Board

Results 1 to 6 of 6

Thread: HTTP + RThread

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    107

    HTTP + RThread

    Is there anything special that needs to be done to make HTTP calls inside a new thread? I spent a few hours trying to fix a simple application that launches a new thread using RThread, sets up cleanup stack support, installs an active scheduler, and then tries to do an HTTP POST using code copied almost entirely from the HTTPExampleClient example app. In the main thread of the application it works perfectly, but in the threaded version it produces a KERN-EXEC 0 at the call to CActiveScheduler::Start() just after calling SubmitL() on the RHTTPTransaction object. Are there any limitations on using the HTTP API outside the application thread?

  2. #2
    Super Contributor
    Join Date
    Jul 2007
    Posts
    596

    Re: HTTP + RThread

    AFAIK there should be no pb and u have to do nothing special for it and u can search the reason for Kernexec 0 in this forum.It is already discussed plenty of times.


    Thanks

  3. #3
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: HTTP + RThread

    Hi,

    1/ There can be many reasons for such behavior - but most probably you have kind of a bug in your code. It is probably not caused by the HTTP itself - try to use some other active object instead, i.e. timer to see if you will have the same error.

    2/ You can post your initalization code here, so we can check it.

    Anyway I do not see big reasons to separate the HTTP processing to the another thread... They're non blocking operations done by separate HTTP process, and your application needs just to get data in the callbacks.

    BR
    STeN

  4. #4
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: HTTP + RThread

    Since the error is that a handle is invalid, this normally happens when you create your sever objects like the RConnection, RHTTPSession, RSocketServ on a different thread.
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  5. #5
    Registered User
    Join Date
    Mar 2006
    Posts
    107

    Re: HTTP + RThread

    Quote Originally Posted by Paul.Todd View Post
    Since the error is that a handle is invalid, this normally happens when you create your sever objects like the RConnection, RHTTPSession, RSocketServ on a different thread.
    This was so obvious in hindsight! I had my RConnection and RSocketServ objects declared as static members of the class containing the threaded function and was calling RSocketServ::Connect and RConnection::Open from the new thread, but of course the objects were being created in the main thread before the other thread was launched. I changed them to local variables in the threaded function and now it all works. I knew KERN-EXEC 0 could be caused by something like that but just overlooked the location of those R-objects somehow. Won't make that mistake again in a hurry...

    Quote Originally Posted by stenlik
    Anyway I do not see big reasons to separate the HTTP processing to the another thread... They're non blocking operations done by separate HTTP process, and your application needs just to get data in the callbacks.
    The thread won't just be doing HTTP requests, it's also going to be running a lot of other code ported from Windows that I don't want to refactor to fit the active object pattern.

  6. #6
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: HTTP + RThread

    Remember under a lot of cases you can use ShareAuto to share sessions in the same process.
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

Similar Threads

  1. How can I call http session simultaneously?
    By gusta72 in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2006-10-19, 19:58
  2. How can I process http sessions at a time?
    By gusta72 in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2006-10-17, 08:29
  3. Replies: 2
    Last Post: 2006-10-06, 17:24
  4. HTTP Client - Synchronous HTTP POST Calls?
    By symbian_ravi in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2006-04-16, 11:51
  5. http connection via a proxy programmatically
    By tiansun in forum Mobile Java General
    Replies: 0
    Last Post: 2005-04-19, 02:47

Posting Permissions

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