Tuesday, December 23, 2014

npm ERR! Error: Attempt to unlock *******, which hasn't been locked

I encountered this error when I was trying to install dependencies for angular-phonecat. The error is misleading. You must be wondering why NPM is trying to unlock something that is not locked. Attempting to run the npm install with sudo as well does not fix the problem. 

The root cause of this problem is that the user who is trying to download npm packages is not the owner of the folder in which the installed packages will be stored.

To fix this, run the following command

sudo chown -R $(whoami) $HOME/.npm

Wednesday, January 9, 2013

Importance of Unit Testing

Interesting infographic from TypeMock. Though it is not easy for all developers to relate to the data provided, I think it emphasizes the importance of unit testing.

The Severity of Bugs: Are We Doomed Infographic

To start easy unit testing, try Typemock.

Monday, February 20, 2012

Could not connect to net.tcp://xxxxxxx.servicebus.windows.net:9354

While learning to use the ServiceBus, I wrote a small application that sends messages to a queue and retrieves based on filters. Initially the application was working fine. But when I wanted to demo it to my collegue, it just wouldn't send or receive messages. I constantly saw the exception

"Could not connect to net.tcp://XXXXX.servicebus.windows.net:9354/. The connection attempt lasted for a time span of 00:00:21.0254249. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"

After some investigation, I figured out that the issue was due to change in environment. When I had initially developed the application, I was working on a network which had no restrictions. But my demo was on my office network that had a firewall with ports locked down. To communicate with the ServiceBus, the SDK uses tcp port 9354.

You can open this port and make the application work. Or if you are going to run your application in an environment where IT will not open ports for your application, you can communicate with the ServiceBus using HTTP.

To communicate using HTTP, before you perform any operations, set the connectivity mode to http.

Microsoft.ServiceBus.ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;

This mode setting applies to all endpoints being used by your application.

Using Http mode has a performance downside compared to Tcp.