+ Reply to Thread
Results 1 to 9 of 9

Thread: Salesforce/PHP - Bulk Outbound message (SOAP), Time out issue

  1. #1
    ppafford is offline Junior Member
    Join Date
    Sep 2009
    Posts
    21

    Salesforce/PHP - Bulk Outbound message (SOAP), Time out issue

    Salesforce can send up to 100 requests inside 1 SOAP message. While sending this type of Bulk Ooutbound message request my PHP script finishes executing but SF fails to accept the ACK used to clear the message queue on the Salesforce side of things. Looking at the Outbound message log (monitoring) I see all the messages in a pending state with the Delivery Failure Reason "java.net.SocketTimeoutException: Read timed out". If my script has finished execution, why do I get this error?

    I have tried these methods to increase the execution time on my server as I have no access on the Salesforce side:

    * set_time_limit(0); // in the script
    * max_execution_time = 360 ; Maximum execution time of each script, in seconds
    * max_input_time = 360 ; Maximum amount of time each script may spend parsing request data
    * memory_limit = 32M ; Maximum amount of memory a script may consume

    I used the high settings just for testing.

    Any thoughts as to why this is failing the ACK delivery back to Salesforce?

    Here is some of the code: This is how I accept and send the ACK file for the imcoming SOAP request

    PHP Code:
    $data 'php://input';
    $content file_get_contents($data);

    if(
    $content) {
        
    respond('true');
    } else {
        
    respond('false');

    The respond function

    function respond($tf) {
    PHP Code:
        $ACK = <<<ACK
    <?xml version "1.0" encoding "utf-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <soapenv:Body>
            <notifications xmlns="http://soap.sforce.com/2005/09/outbound">
                <Ack>$tf</Ack>
            </notifications>
        </soapenv:Body>
    </soapenv:Envelope>
    ACK;

        print trim($ACK); 
    }
    These are in a generic script that I include into the script that uses the data for a specific workflow. I can process about 25 requests (That are in 1 SOAP response) but once I go over that I get the timeout error in the Salesforce queue. for 50 requests is usually takes my PHP script 86.77 seconds.

    Could it be Apache? PHP?

    I have also tested just accepting the 100 request SOAP response and just accepting and sending the ACK the queue clears out, so I know it's on my side of things.

    I show no errors in the apache log, the script runs fine.

    I did find some info on the Salesforce site but still no luck. Here is the link.

    Also I'm using PHP Toolkit 11 if that helps at all.

    StackOverFlow Link


    Thanks for any insight into this, --Phill

  2. #2
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    I know that I have had issues in the past with the timeout from salesforce and few weeks ago, I posted a question to their development team about their timeout functionality. I have yet to hear back from them. So you are not alone in your issue

    What are you doing that is sending out 100 messages at one time. that seems like quite a bit

    ~Mike

  3. #3
    ppafford is offline Junior Member
    Join Date
    Sep 2009
    Posts
    21
    I have some server side processes that raise cases to SF, these usually kick off about 10 to 100 cases that go into a queue (So they could just be from build up as well from running over night). Just doing a assign to function also kicks off a OBM and since I can do a bulk assign to this issue has started to occur.

    The simplest way to test would be to:

    1. Create a test or testing status for the case
    2. Create an outbound message when this status is selected
    3. Created 101 test cases
    4. Do a bulk status change to test or testing
    If I just send back the ACK for this type of test it works great, but if I do any type of processing the SOAP request I get the time out error. I was thinking it might be a memory issue since I'm dealing with such large data sets. Will post back if I have any findings today.

    Thanks again Mike,
    --Phill

  4. #4
    ppafford is offline Junior Member
    Join Date
    Sep 2009
    Posts
    21
    This is a huge issue right now for me, anyone have a solution. Pulling out my hair .

    Thanks for any input on this,
    --Phill

  5. #5
    ppafford is offline Junior Member
    Join Date
    Sep 2009
    Posts
    21
    okay I think I have the problem:

    PHP uses the single thread processing approach and will not send back the ACK file until the thread has completed it's processing. Is there a way to make this a mutli thread process?
    Thread #1 - accept the incoming SOAP request and send back the ACK
    Thread #2 - Process the SOAP request

    I'm going to try to close the socket after the ACK submission and continue the processing, cross my fingers it will work.

  6. #6
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    I am having the same issues and cannot figure it out. I thought that I was sending the ACK as soon as I received the whole message, once it was done reading content. Maybe we can work together on this man, but would like to know your finidings

    ~Mike

    PS: I found out today that I have a ruptured C6 in my upper back. I do not know what is going to happen right now, but will work with you as much as I can

  7. #7
    ppafford is offline Junior Member
    Join Date
    Sep 2009
    Posts
    21
    Best of luck to you on your back, I as well have had issues with ruptured discs. Send me an email if you have any questions. phillpafford [at] gmail [dot] com

    As for the SF/PHP OBM bulk messaging issue here is what I have found out:

    • PHP is a single thread process, which means i has to complete the processing before sending back the ACK (Regardless of when you send it)
    • The timeout of SF side of things has a 60 second limit as this is standard with SOAP
    • SF might be able to increase the 60 threshold but I don't think this is the best approach
    Things I would like to test:
    Let me know if you have any ideas as well.

    Thanks,
    --Phill

  8. #8
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    Thanks I just might send you an email to get feedback on what exactly you did with your ruptured disks, man it sure is painful as hell

    again as for the outbound message issues. What about this approach, which I have not tried yet. What about having a script that writes the data to a flat file and then sending the ACK once that is complete. Then have another script that updates the data from the text file and deletes it when it is done?

  9. #9
    ppafford is offline Junior Member
    Join Date
    Sep 2009
    Posts
    21
    I think storing the data in a Flat file/ DB Table would be the last option as this breaks it into multiple scripts and CRON configuration.

    I have tested out the Flat file/ DB Table already by trying to kick off the processing script from the receiving script.

    • Receive incoming SOAP request
    • Write to file/DB
    • Send ACK
    • execute processing script like this:
      • $cmd = `php /path/to/precess.php`; echo $cmd; // Using Back ticks
      • exec('php /path/to/precess.php');
    Still the incoming script waits for the processing script to finish before sending the ACK.

    The only other option this way would be to run the processing script in CRON at a very low interval like every minute or every 5 minutes. This is my last resort if nothing else works, but optimistic on finding another solution

    --Phill

+ Reply to Thread

Similar Threads

  1. Using Salesforce Outbound SOAP Messages with PHP
    By mike in forum Salesforce PHP Tutorials
    Replies: 49
    Last Post: 07-10-2010, 03:14 PM
  2. Outbound Messages + Merge Records
    By ambiguator in forum Salesforce PHP Tutorials
    Replies: 10
    Last Post: 09-29-2009, 01:24 PM
  3. Issue while inserting new task into salesfore using PHP
    By blessang in forum Salesforce Coding Discussions
    Replies: 1
    Last Post: 12-07-2008, 09:37 PM
  4. Needed: Time Zone in salesforce
    By pankajshukla2282 in forum Salesforce Coding Discussions
    Replies: 1
    Last Post: 11-29-2008, 12:44 PM
  5. QueryMore returns 4 rows at a time
    By bakum in forum Salesforce Coding Discussions
    Replies: 5
    Last Post: 02-08-2008, 07:25 AM

Bookmarks

Posting Permissions

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

SEO by vBSEO 3.5.1