Expand my Community achievements bar.

Are there any size limits on MessageItem.body in Server to Server API?

Avatar

Level 2

Hi, I am using Server to Server API to push changes to connected clients, but there seems to be some size limits on message body? To confirm this I have PHP sample code.

When I send $smallMessage it successfully updated on the node and show up in LCCS room console,

$message is sent without any error or warnings but it dos not appear on the node in room console

But when I send $bigMessage it throws exception( exception log is listed blow the code )

<?php

require_once("afcs.php");

     $accountURL     = "https://connectnow.acrobat.com/xxxxx";
     $devUser  = "xxxxxxxxxxxxxxxxxx";
     $devPassoword     = "xxxxxxxx";
     $roomID = "tmp12";
     $collectionID = "notifications";
     $nodeID = "notificationNode";


     AFCS::$DEBUG = true;
     $afcsAccount = new AFCSAccount($accountURL);
     try {
          echo"<br><b>login</b><br>";
          $afcsAccount->login( $devUser , $devPassoword );
     }
     catch (AFCSError $error ) {
          echo"<br><b>login exception</b><br>";
          echo $error;
     }

     try {
          echo"<br><b>publishing item</b><br>";
          $smallMessage = "this is small message";
          $message = "s I said earlier tonight, code doesn’t lie. Facebook has now confirmed their location-based feature,
                     which is apparently due to launch shortly if the code found on their touch.facebook.com site is any indication
                     Of course, they only confirmed it so they could clarify something else";

          $bigMessage = "s I said earlier tonight, code doesn’t lie. Facebook has now confirmed their location-based feature,
                     which is apparently due to launch shortly if the code found on their touch.facebook.com site is any indication
                     Of course, they only confirmed it so they could clarify something elses I said earlier tonight, code doesn’t lie. Facebook has now confirmed their location-based feature,
                     which is apparently due to launch shortly if the code found on their touch.facebook.com site is any indication
                     Of course, they only confirmed it so they could clarify something elses I said earlier tonight, code doesn’t lie. Facebook has now confirmed their location-based feature,
                     which is apparently due to launch shortly if the code found on their touch.facebook.com site is any indication
                     Of course, they only confirmed it so they could clarify somethingOf course, they only confirmed it so they could clarify something elses I said earlier tonight, code doesn’t lie. Facebook has now confirmed their location-based feature,
                     which is apparently due to launch shortly if the code found on their touch.facebook.com site is any indication
                     Of course, they only confirmed it so they could clarify something";

          $messageItem = array("nodeName"=>$nodeID,"body"=>$bigMessage);

          $afcsAccount->publishItem($roomID, $collectionID, $nodeID,$messageItem );
     }
     catch (AFCSError $error ) {
          echo"<br><b>publishing item exception</b><br>";
          echo$error;
     }

?>

Error Log

$Revision: #3 $ - $Date: 2010/04/13 $ http_get:  https://connectnow.acrobat.com/xxxxxx?mode=xml&accountonly=true& 
login
http_post:  https://services.acrobat.com/account/wsapi/auth/v1  xxxxxxxxxxxxxxxxxxxxxxxx  Array ( [Content-Type] => text/xml ) renga*na1r*12883324a8f*V81Q8SXH1D79XFF461BT96VD98  Array ( ) http_get:  https://na2.connectnow.acrobat.com:443/xxxxxxxxxx?mode=xml&accountonly=true&gak=cmVuZ2EqbmExcioxMjg4...
publishing item
http_post:  https://na2.connectnow.acrobat.com:443/app/rtc?instance=na2-sdk-9c14463c-0123-48b8-9724-3345da49ad99... notificationNode&gak=cmVuZ2EqbmExcioxMjg4MzMyNGE4ZipWODFROFNYSDFENzlYRkY0NjFCVDk2VkQ5OA==  notificationNode I said earlier tonight, code doesn’t lie. Facebook has now  confirmed their location-based feature, which is apparently due to launch  shortly if the code found on their touch.facebook.com site is any indication Of  course, they only confirmed it so they could clarify something elses I said  earlier tonight, code doesn’t lie. Facebook has now confirmed their  location-based feature, which is apparently due to launch shortly if the code  found on their touch.facebook.com site is any indication Of course, they only  confirmed it so they could clarify something elses I said earlier tonight, code  doesn’t lie. Facebook has now confirmed their location-based feature, which is  apparently due to launch shortly if the code found on their touch.facebook.com  site is any indication Of course, they only confirmed it so they could clarify  somethingOf course, they only confirmed it so they could clarify something elses  I said earlier tonight, code doesn’t lie. Facebook has now confirmed their  location-based feature, which is apparently due to launch shortly if the code  found on their touch.facebook.com site is any indication Of course, they only  confirmed it so they could clarify something  Array ( [Content-Type] => text/xml )
Warning:  fopen(https://na2.connectnow.acrobat.com:443/app/rtc?instance=na2-sdk-9c14463c-0123-48b8-9724-3345da49ad99/xxxxxxx&action=publish&collection=notifications&node= notificationNode&gak=cmVuZ2EqbmExcioxMjg4MzMyNGE4ZipWODFROFNYSDFENzlYRkY0NjFCVDk2VkQ5OA==)  [function.fopen]: failed to open stream: HTTP  request failed! in  D:\xampp\htdocs\xxxxxx\amfphp1_9\services\test\afcs.php on line  829

publishing item exception
exception 'AFCSError' with  message 'connection-failed' in  D:\xampp\htdocs\xxxxx\amfphp1_9\services\test\afcs.php:831 Stack trace: #0  D:\xampp\htdocs\xxxxxx\amfphp1_9\services\test\afcs.php(587):  AFCS->http_post('https://na2.con...', 'publishItem('xxxxxx',  'notifications', 'notificationNode', Array) #2 {main}

12 Replies

Avatar

Former Community Member

I tried your large message in the moderated chat (sampleApps/Server2Server/ModeratedChat_PHP/server/flashservices/services/ChatModerator.php), it went though ok.  Only thing I can see then difference is that following

Dean

Avatar

Level 2

I have tested it with

AFCS::$USE_CURL = true;

This time $bigMessage is sent without errors but it does not appear on the node in room console, also connected clients do not receive it.

Avatar

Former Community Member

After reading more into your error log, it seems that your room was not launched before you publishing your Item, thus - (Exception 'AFCSError' with  message 'connection-failed' in) or your room was not in a good state.

I didn't use "USE_CURL", only using the default stream and it works for me.

Can you share your client code that subscribe to the same node?  (did you subscribe to the node and listening on the receiveItem event?)

btw, here is the example code I used:  (i did not get error)

Avatar

Former Community Member

actually, publishItem will start the room if it is not started.  your connection-error might be coming from your php server, any more log from your server will be helpful for diagnosis.  You can verify your node is created correctly using the getNodeConfiguration call.   But it will be helpful to see your client code for receiveItem.

example of using getNodeConfiguration:

Avatar

Level 2

Summery of the problem

Using Server2Server API $smallMessage is sent successfully, $bigMessage throws same exception, $message is sent without errors but doesn’t appear both in client and notificationNode in room console.

Below are client code and logs for apache, room console, php

i have executed this statement in the server test code below

echo "<b>node cofig:</b>".$afcsAccount->getNodeConfiguration($roomID, $collectionID, $nodeID);

and got this: node cofig: false10.0

One strange thing I have noted when

I sent first message on this notificationNode from client and 2nd from server, this node shows both messages in room console, but the storage scheme for the node is set to SINGLE_ITEM

Room console log for message sent from client

publisherID: WCD-1C9E5BFB4BA260720A04B82C/4

associatedUserID: WCD-1C9E5BFB4BA260720A04B82C/2

timeStamp: 1273676782189

body:"message from client"

Room console log for message sent from server

publisherID: null

associatedUserID: __server__

timeStamp: -1

body:

"Message from server"

Apache php_error.log

[12-May-2010 15:49:13] PHP Warning:  fopen(https://na2.connectnow.acrobat.com:443/app/rtc?instance=na2-sdk-f9f8d5be-fc75-4668-b30b-87715fe042b2/myfirstroom&amp;action=publish&amp;collection=notifications&amp;node=notificationNode&amp;gak=cmVuZ2EqbmExcioxMjg4ZDM3YTIwOSpTRlFORkg2WFZIMEpRM0dUMUNUQ1RDQUFKTQ==) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: HTTP request failed!  in D:\xampp\htdocs\xxxxx\amfphp1_9\services\test\afcs.php on line 829

Apache error.log

[Wed May 12 20:33:23 2010] [notice] Digest: generating secret for digest authentication ...
[Wed May 12 20:33:23 2010] [notice] Digest: done
[Wed May 12 20:33:23 2010] [notice] Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Wed May 12 20:33:23 2010] [notice] Server built: Nov 11 2009 14:29:03
[Wed May 12 20:33:23 2010] [notice] Parent: Created child process 2276
[Wed May 12 20:33:26 2010] [notice] Digest: generating secret for digest authentication ...
[Wed May 12 20:33:26 2010] [notice] Digest: done
[Wed May 12 20:33:26 2010] [notice] Child 2276: Child process is running
[Wed May 12 20:33:26 2010] [notice] Child 2276: Acquired the start mutex.
[Wed May 12 20:33:26 2010] [notice] Child 2276: Starting 150 worker threads.
[Wed May 12 20:33:26 2010] [notice] Child 2276: Starting thread to listen on port 80.
[Wed May 12 20:33:26 2010] [notice] Child 2276: Starting thread to listen on port 443.

Client Code

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
                              xmlns:authentication="com.adobe.rtc.authentication.*" xmlns:session="com.adobe.rtc.session.*" xmlns:util="com.adobe.rtc.util.*"
                              creationComplete="onCreationComplete();">
     <mx:Label id="connectLabel"  horizontalCenter="0" y="10"/>
     <mx:TextArea id="input" text="" left="20" height="40" bottom="5" right="20" fontSize="12" keyDown="input_keyDownHandler(event)"
                      change="input_changeHandler(event)"/>
     <mx:TextArea id="output" text="" left="20" top="50" bottom="50" right="20" fontSize="13" fontWeight="bold" updateComplete="output_updateCompleteHandler(event)"/>
    
     <authentication:AdobeHSAuthenticator id="auth" userName="xxxxxxx" password="xxxxxxx"/>
     <session:ConnectSessionContainer id="cSession" authenticator="{auth}"
                                              roomURL="https://connectnow.acrobat.com/xxxxxxx/myfirstroom"  autoLogin="false" synchronizationChange="onSnycChange(event);">
     </session:ConnectSessionContainer>
     <mx:Script>
          <![CDATA[
               import com.adobe.rtc.events.CollectionNodeEvent;
               import com.adobe.rtc.events.SessionEvent;
               import com.adobe.rtc.messaging.MessageItem;
               import com.adobe.rtc.messaging.NodeConfiguration;
               import com.adobe.rtc.messaging.UserRoles;
               import com.adobe.rtc.session.ConnectSession;
               import com.adobe.rtc.sharedModel.CollectionNode;
               import com.adobe.rtc.util.DebugUtil;
              
               import mx.events.FlexEvent;
              
               private static const NOTIFICATION_NODE:String = "notificationNode";
               private var collectionNode:CollectionNode;
              
              
               private function onCreationComplete():void {
                    //DebugUtil.traceFunction = myTrace;
                    cSession.login();
                    connectLabel.htmlText = "<FONT COLOR='#b96a04' FACE='Verdana,Tahoma' SIZE ='15'><B>CONNECTING...</B></FONT>";
                   
                   
                    collectionNode = new CollectionNode();
                    collectionNode.sharedID = "notifications";
                    collectionNode.addEventListener(CollectionNodeEvent.SYNCHRONIZATION_CHANGE , onCollectionNodeSyncChange , false , 0 , true );
                    collectionNode.addEventListener(CollectionNodeEvent.ITEM_RECEIVE , onItemReceive , false , 0 , true );
                   
               }
              
               private function myTrace( message:String ):void {
                    output.text+= message + "\n";
               }
              
               private function onSnycChange(event:SessionEvent):void {
                    if( cSession.isSynchronized )  {
                         connectLabel.htmlText = "<FONT COLOR='#067f06' FACE='Verdana,Tahoma' SIZE ='15'><B>CONNECTED</B></FONT>";
                         collectionNode.connectSession = ConnectSession.primarySession;
                         collectionNode.subscribe();
                    }
                    else {
                         connectLabel.htmlText = "<FONT COLOR='#b90404' FACE='Verdana,Tahoma' SIZE ='15'><B>DISCONNECTED</B></FONT>";
                    }
               }
              
               private function onCollectionNodeSyncChange(event:CollectionNodeEvent):void {
                    if ( collectionNode.isSynchronized )  {
                         if ( collectionNode.canUserConfigure ( ConnectSession.primarySession.userManager.myUserID , NOTIFICATION_NODE ) )  {
                              if ( ! collectionNode.isNodeDefined( NOTIFICATION_NODE ) )  {
                                   var chatNodeConfig:NodeConfiguration = new NodeConfiguration();
                                   chatNodeConfig.persistItems = false;
                                   chatNodeConfig.publishModel = UserRoles.VIEWER;
                                   chatNodeConfig.accessModel = UserRoles.VIEWER;
                                   collectionNode.createNode( NOTIFICATION_NODE , chatNodeConfig );
                                   trace(NOTIFICATION_NODE +" created");
                              }
                         }
                         trace("notification collection sync complete");
                    }
               }
              
               private function onItemReceive(event:CollectionNodeEvent):void {
                    if ( event.nodeName == NOTIFICATION_NODE )
                         myTrace( event.item.body );
               }
              
               private function sendNotification( msg:String ):void {
                    if ( collectionNode.isSynchronized ) {
                         var messageItem:MessageItem = new MessageItem( NOTIFICATION_NODE , msg );
                         collectionNode.publishItem( messageItem );
                    }                   
               }
              
              
               protected function input_keyDownHandler(event:KeyboardEvent):void
               {
                    //event.stopImmediatePropagation();
                    if( event.keyCode == Keyboard.ENTER || event.keyCode == Keyboard.NUMPAD_ENTER ) {
                         event.preventDefault();
                         var text:String = input.text;
                         if( text.length ) {
                              sendNotification( text );
                              input.text = "";
                         }
                    }
               }


               protected function input_changeHandler(event:Event):void
               {
                   
               }


               protected function output_updateCompleteHandler(event:FlexEvent):void
               {
                    output.verticalScrollPosition = output.maxVerticalScrollPosition;
               }

          ]]>
     </mx:Script>
</mx:WindowedApplication>

ServerCode

<?php

require_once("afcs.php");

     $accountURL      = "https://connectnow.acrobat.com/xxxxxx";
     $devUser     = "xxxxxxxxxx";
     $devPassword     = "xxxxxxxx";
     $roomID = "myfirstroom";
     $collectionID = "notifications";
     $nodeID = "notificationNode";


     AFCS::$DEBUG = true;
     $afcsAccount = null;//new AFCSAccount($accountURL);

      try {
        if(isset($_SESSION['AFCSAccount']))
        {
                //login to afcs only require once
                $afcsAccount = unserialize($_SESSION['AFCSAccount']);
                $afcsAccount->keepalive();
        }
        else {
                // Login once, do the handshake once for your account and then call multiple API
                $afcsAccount = new AFCSAccount($accountURL);
                $afcsAccount->login($devUser, $devPassword);
                $_SESSION['AFCSAccount'] = serialize($afcsAccount);
        }

     }
     catch (AFCSError $error ) {
          echo"<br><b>login exception</b><br>";
          echo $error;
     }

     try {

          //header("Content-type: text/xml");
        echo "<b>node cofig:</b>".$afcsAccount->getNodeConfiguration($roomID, $collectionID, $nodeID);

          echo"<br><b>publishing item</b><br>";
          $smallMessage = "Message from server...2";
          $message = "Message from server: I said earlier tonight, code doesn’t lie. Facebook has now confirmed their location-based feature,
                     which is apparently due to launch shortly if the code found on their touch.facebook.com site is any indication
                     Of course, they only confirmed it so they could clarify something else";

          $bigMessage = "Message from server: I said earlier tonight, code doesn’t lie. Facebook has now confirmed their location-based feature,
                     which is apparently due to launch shortly if the code found on their touch.facebook.com site is any indication
                     Of course, they only confirmed it so they could clarify something elses I said earlier tonight, code doesn’t lie. Facebook has now confirmed their location-based feature,
                     which is apparently due to launch shortly if the code found on their touch.facebook.com site is any indication
                     Of course, they only confirmed it so they could clarify something elses I said earlier tonight, code doesn’t lie. Facebook has now confirmed their location-based feature,
                     which is apparently due to launch shortly if the code found on their touch.facebook.com site is any indication
                     Of course, they only confirmed it so they could clarify somethingOf course, they only confirmed it so they could clarify something elses I said earlier tonight, code doesn’t lie. Facebook has now confirmed their location-based feature,
                     which is apparently due to launch shortly if the code found on their touch.facebook.com site is any indication
                     Of course, they only confirmed it so they could clarify something";

          $messageItem = array("nodeName"=>$nodeID,"body"=>$bigMessage);

          $afcsAccount->publishItem($roomID, $collectionID, $nodeID,$messageItem );
     }
     catch (AFCSError $error ) {
          echo"<br><b>publishing item exception</b><br>";
          echo$error;
     }

?>

Server Log

$Revision: #3 $ - $Date: 2010/04/13 $ http_get:
https://connectnow.acrobat.com/xxxxxxxx?mode=xml&accountonly=true&;
http_post:
https://services.acrobat.com/account/wsapi/auth/v1
xxxxxxxxxxxxxxxxx
Array ( [Content-Type] => text/xml ) renga*na1r*1288d37a209*SFQNFH6XVH0JQ3GT1CTCTCAAJM
Array ( ) http_get:
https://na2.connectnow.acrobat.com:443/xxxxxx?mode=xml&accountonly=true&gak=cmVuZ2EqbmExcioxMjg4ZDM3...
http_get:
https://na2.connectnow.acrobat.com:443/app/rtc?instance=na2-sdk-f9f8d5be-fc75-4668-b30b-87715fe042b2...
node cofig: false10.0

publishing item
http_post:
https://na2.connectnow.acrobat.com:443/app/rtc?instance=na2-sdk-f9f8d5be-fc75-4668-b30b-87715fe042b2...
notificationNodeMessage from server: I said earlier tonight, code doesn’t lie.
Facebook has now confirmed their location-based feature, which is apparently due
to launch shortly if the code found on their touch.facebook.com site is any
indication Of course, they only confirmed it so they could clarify something
elses I said earlier tonight, code doesn’t lie. Facebook has now confirmed their
location-based feature, which is apparently due to launch shortly if the code
found on their touch.facebook.com site is any indication Of course, they only
confirmed it so they could clarify something elses I said earlier tonight, code
doesn’t lie. Facebook has now confirmed their location-based feature, which is
apparently due to launch shortly if the code found on their touch.facebook.com
site is any indication Of course, they only confirmed it so they could clarify
somethingOf course, they only confirmed it so they could clarify something elses
I said earlier tonight, code doesn’t lie. Facebook has now confirmed their
location-based feature, which is apparently due to launch shortly if the code
found on their touch.facebook.com site is any indication Of course, they only
confirmed it so they could clarify something
Array ( [Content-Type] => text/xml )
Warning:
fopen(https://na2.connectnow.acrobat.com:443/app/rtc?instance=na2-sdk-f9f8d5be-fc75-4668-b30b-87715fe042b2/myfirstroom&action=publish&collection=notifications&node=notificationNode&gak=cmVuZ2EqbmExcioxMjg4ZDM3YTIwOSpTRlFORkg2WFZIMEpRM0dUMUNUQ1RDQUFKTQ==)
[function.fopen]: failed to open stream: HTTP
request failed! in
D:\xampp\htdocs\xxxxxx\amfphp1_9\services\test\afcs.php on line
829

publishing item exception
exception 'AFCSError' with
message 'connection-failed' in
D:\xampp\htdocs\xxxxx\amfphp1_9\services\test\afcs.php:831 Stack trace: #0
D:\xampp\htdocs\xxxxx\amfphp1_9\services\test\afcs.php(587):
AFCS->http_post('https://na2.con...', 'publishItem('myfirstroom', 'notifications', 'notificationNod...',
Array) #2 {main}

Avatar

Former Community Member

I was able to run your client and receiving the bigMessage using server php code.  (please see screen shot of your client).  I notice you got a http error in your server log:  Can you verify your server http setting for handling larger data?

for example:

add: ini_set ('user_agent', $_SERVER['HTTP_USER_AGENT']); in your php code or in your php.ini (see http://bugs.php.net/bug.php?id=22937#c64196)

[function.fopen]: failed to open stream: HTTP 
request failed! in 
D:\xampp\htdocs\xxxxxx\amfphp1_9\services\test\afcs.php on line
829

test.jpg

Avatar

Level 2

Hi DeanXC,

I have tried setting ini_set ('user_agent', $_SERVER['HTTP_USER_AGENT']); in code and  in php.ini but no success. I use xampp  as a dev server, with all its default settings for apache, mysql and php. On my office network it throws exception on sending $bigMessage . I have also tried it at home, on my home network it sends $bigMessage without any exception, but that message is not received on the node, neither in room console nor in the client app. Would you please try it again using xampp?

Avatar

Former Community Member

BTW, thanks for using our Server to Server feature. It is always pleasure to see the feature in use.  The reason you don't see item in your room console is because the nodeConfiguration set up for your node does not persist your item (it goes away once your publishItem), so only intended user see it, but your room console does not.  You can turn the persistItem flag to true in your room console for your node under "explore" tag and see if your publish goes through.   I still can't explain your client not seeing the message, because I am using your client and it is working for me.  Can you reveal your account name and room name so I can verify on our end (you can send me private message if you like)

thanks

Dean

Avatar

Level 2

Hi, I have sent you lccs account info, I am still experiencing the same problem for $bigMessages

As publishItem($bigMessage) results in error, subsequent successfully sent $smallMessages started to accumulate in node even when storage scheme for the node is set to SINGLE_ITEM, as in screenshots. In first image messages 0,1,2 are sent from server.

room_state_1.png

room_state_2.png

Avatar

Former Community Member

Hi Ali,

I will take a look at your account and let you know.

thanks

Dean

Avatar

Employee

The reason why your publishItem(s) don't override each other is, I think, because you are not passing an itemID.

I know this may sound odds, but currently even if storage scheme is set to SINGLE_ITEM if you don't pass an itemID the server will assign a unique one to each item and keep them all.

If you pass the same itemID (as part of the item payload) every time you call publishItem the server will honor the storage scheme and override the existing item.

In the Flex SDK the client take care of this, but in the server-side code we didn't add yet all these checks.

Please try and let us know if that fixed your problem.

Regarding publishing large message bodys, again, your message is not exactly large (a few hundred bytes) and we don't do any check server-side.

I have looked at our logs trying to match your traces but I didn't find any request that looks like yours so we suspect it's something on your server that is blocking the request. And we tried our code and it worked for us.

Any way you can trace the HTTP requests and make sure that the request that fails is trying to contact our server ?

Also, what version of PHP are you using ? And on what system ? (Linux, Windows?)

Avatar

Level 2

Hi Raff.

I am using XAMPP  on windows xp service pack 2 with all its default settings

it has  Apache 2.2.14 (IPv6 enabled) + OpenSSL 0.9.8l and PHP 5.3.1