Azure IoT Hub connect error from node app - cannot read property 'write' of null in amqp libs
stream.write(buffer, callback);
^
TypeError: Cannot read property 'write' of null
Turns out it may be the connection string I was using
Connection String causing timeouts
So I was defaulting to this format
HostName=somewhere.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=<yours>
This would cause the error above intermittently, and I wanted to resolve it.
Turns out you can use another connection string format:
Endpoint=sb://yourshere.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=;yours;EntityPath=yourEntityPath;
To find these values, go into Azure, go to your IoT hub, Messaging, Endpoints and click on the Events endpoint below:
A properties window will appear.HostName=somewhere.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=<yours>
This would cause the error above intermittently, and I wanted to resolve it.
Turns out you can use another connection string format:
Endpoint=sb://yourshere.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=;yours;EntityPath=yourEntityPath;
To find these values, go into Azure, go to your IoT hub, Messaging, Endpoints and click on the Events endpoint below:
The Event Hub-compatible name goes in the yourEntityPath value.
The Event Hub-compatible endpoint is where you would enter the Endpoint.
I found the problem and resolution here. I haven't encountered the error "Cannot read property 'write' of null" again.
IoT is way more fun than the old days when I used to send frames down the serial port, using c++, or getting values from a PLC or a weigh bridge. Probably even more fun than the Win SC API. But working with those devices is always good fun.
Cheers
QuintesConnect with me on LinkedIn or Twitter