Archive for June, 2013

Azure and the “Cannot read property ‘isSuccessful’ of null” error

Working on a nodejs project for azure the following error appeared when using queues:

C:\workspaces\demo\node_modules\azure\lib\services\queue\queueservice.js:582
callback(returnObject.error, returnObject.response.isSuccessful, returnO
^
TypeError: Cannot read property 'isSuccessful' of null
at QueueService.deleteMessage.finalCallback (C:\workspaces\demo\node_modules\azure\lib\services\queue\queueservice.js:582:57)
at ServiceClient._initDefaultFilter.filter (C:\workspaces\demo\node_modules\azure\lib\services\core\serviceclient.js:602:11)
at QueueService.deleteMessage.processResponseCallback (C:\workspaces\demo\node_modules\azure\lib\services\queue\queueservice.js:585:5)
at Request.ServiceClient._performRequest.self._buildRequestOptions.processResponseCallback [as _callback] (C:\workspaces\demo\node_modules\azure\lib\services\core\serviceclient.js:239:11)
at Request.init.self.callback (C:\workspaces\demo\node_modules\azure\node_modules\request\index.js:148:22)
at Request.EventEmitter.emit (events.js:88:17)
at ClientRequest.Request.init.self.clientErrorHandler (C:\workspaces\demo\node_modules\azure\node_modules\request\index.js:257:10)
at ClientRequest.EventEmitter.emit (events.js:88:17)
at CleartextStream.socketCloseListener (http.js:1304:9)
at CleartextStream.EventEmitter.emit (events.js:115:20)

That happened because in the queueservice.js file the deleteMessage function was defined as follows:

QueueService.prototype.deleteMessage = function (queue, messageid, popreceipt, optionsOrCallback, callback) {
var options;
azureutil.normalizeArgs(optionsOrCallback, callback, function (o, c) { options = o; callback = c; });

validate.validateArgs('deleteMessage', function (v) {
v.string(queue, 'queue');
v.queueNameIsValid(queue);
v.callback(callback);
});

if (!popreceipt) {
throw new Error('A message retrieved using \'peekMessages\' can not be deleted! Use \'getMessages\' instead.');
}

var webResource = WebResource.del(queue + '/messages/' + messageid)
.withQueryOption(QueryStringConstants.POP_RECEIPT, popreceipt, null, true);

var processResponseCallback = function (responseObject, next) {
var finalCallback = function (returnObject) {
callback(returnObject.error, returnObject.response.isSuccessful, returnObject.response);
};

next(responseObject, finalCallback);
};

this.performRequest(webResource, null, options, processResponseCallback);
};

If you look at the code, you will see a part that reads callback(returnObject.error, returnObject.response.isSuccessful, returnObject.response);.
We’ll this part was causing an error because returnObject.response was null.
The problem with this is that azure (at least the nodejs SDK) uses returnObject.response as null when an error was captured when processing a request… so the same guys use returnObject.response as null and then try to read it -_-

My solution was to check the returnObject before:

var isSuccessful = (returnObject.response == null)?false:returnObject.response.isSuccessful;
callback(returnObject.error, isSuccessful, returnObject.response);

Maybe is not the best solution, but at least now this is working!

Setting a nodejs version in your azure development environment

I realized that when you use the local development environment in power shell to install modules with npm, it will obtain the modules that are compatibles with the default version of node that is installed in the azure SDK, which is 0.6.2.

I commonly use 0.8.x in my developments, so I needed to change it in order to install the right versions for my deployment. Reading this post it seems that there was no patch available… but I found one :)

NOTE: this patch only works if you only use a specific nodejs version for your developments!

– Open the windows power shell environment, and run

Get-AzureServiceProjectRoleRuntime

– You’ll see a list of runtimes available for azure, like

Runtime : Node
Version : 0.6.17
PackageUri : http://az413943.vo.msecnd.net/node/0.6.17.exe
IsDefault : False

Runtime : Node
Version : 0.6.20
PackageUri : http://az413943.vo.msecnd.net/node/0.6.20.exe
IsDefault : True

Runtime : Node
Version : 0.8.4
PackageUri : http://az413943.vo.msecnd.net/node/0.8.4.exe
IsDefault : False

Runtime : IISNode
Version : 0.1.21
PackageUri : http://az413943.vo.msecnd.net/iisnode/0.1.21.exe
IsDefault : True

Runtime : Cache
Version : 1.8.0
PackageUri : http://az413943.vo.msecnd.net/cache/1.8.0.exe
IsDefault : True

Runtime : PHP
Version : 5.3.17
PackageUri : http://az413943.vo.msecnd.net/php/5.3.17.exe
IsDefault : True

Runtime : PHP
Version : 5.4.0
PackageUri : http://az413943.vo.msecnd.net/php/5.4.0.exe
IsDefault : False

There is a package uri for each runtime. Check for the one that you want to use, in my case Node 0.8.4: http://az413943.vo.msecnd.net/node/0.8.4.exe

Download that file, and then install it. That’s all! Now you are ready to go and use the nodejs version that you wanted to use.

Hope this helps!

Azure and Eclipse: deployment with remote desktop enabled

Hi,
After a long time I decided to post here my findings on using Eclipse as a development tool for Azure (we have free credits, so why not?!)

My first issue was how to publish a project to azure with remote desktop support from within Eclipse. At first I achieved this by uploading the project without remote desktop support, since the “Publish” button did not work when using the remote connection option from Eclipse.

After reading the Eclipse logs, I found the following entry:

!ENTRY WAEclipsePlugin 4 0 2013-06-12 11:22:03.460
!MESSAGE Error occurred while configuring remote access.
!STACK 0
java.lang.Exception: Exception occurred while invoking encutil
at com.microsoftopentechnologies.wacommon.utils.EncUtilHelper.encInvocation(EncUtilHelper.java:122)
at com.microsoftopentechnologies.wacommon.utils.EncUtilHelper.getThumbPrint(EncUtilHelper.java:65)
at com.gigaspaces.azure.wizards.DeployWizard.handleRDPSettings(DeployWizard.java:318)
at com.gigaspaces.azure.wizards.DeployWizard.performFinish(DeployWizard.java:115)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:827)

bla,bla,bla

Caused by: java.lang.Exception: The system cannot find the file specified.
at com.microsoftopentechnologies.wacommon.utils.EncUtilHelper.encInvocation(EncUtilHelper.java:118)
... 47 more

So I thounght that maybe the encutil file was not found…. but the error was so hard to read, so I decided to download and recompile the wacommon plugin for azure from HERE.

I modified the EncUtils file, so I can see the whole command that was issued from the plugin.
Basically, I changed the line 122 (or 123…I am not sure :) ) that showed the exception for the following:

throw new Exception("Exception occurred while invoking " + Arrays.toString(command) , e);

After compiling and installing this new plugin (I removed the old one and I accepted the installation without a signature), the following appeared at the log

!ENTRY WAEclipsePlugin 4 0 2013-06-12 11:45:33.870
!MESSAGE Error occurred while configuring remote access.
!STACK 0
java.lang.Exception: Exception occurred while invoking [C:\programs\programming\eclipse\plugins\com.persistent.winazure.eclipseplugin\encutil, -thumbprint, -cert, C:\workspaces\fantaxico\CentralServerAzure\cert\SampleRemoteAccessPublic.cer]
at com.microsoftopentechnologies.wacommon.utils.EncUtilHelper.encInvocation(EncUtilHelper.java:123)
at com.microsoftopentechnologies.wacommon.utils.EncUtilHelper.getThumbPrint(EncUtilHelper.java:66)
at com.gigaspaces.azure.wizards.DeployWizard.handleRDPSettings(DeployWizard.java:318)
at com.gigaspaces.azure.wizards.DeployWizard.performFinish(DeployWizard.java:115)

Now, wait a minute…that is not the certificate I am using!! I use my own certificate in this project. WTF!
I searched for “SampleRemoteAccessPublic” on my project and it was not found anywhere… so something was hardcoded somewhere and was making my deployment to fail.

The solution was to copy the certificate I was using (and the pfx too) to the folder the plugin was expected and rename them to SampleRemoteAccessPublic.cer and SampleRemoteAccessPublic.pfx.

Not the nicest solution, but at least it is working now!