coderholic

Blackberry OS 4.5 "Connection not writeable" Error

When deploying an application that worked fine on Blackberry OS 4.2 I was surprised to come across the following error message on devices running version 4.5 of the OS:

Connection not writeable

The error was shown when trying to create a HTTP connection, using my getWebData method. I tracked the problem down to the following line:

connection = (HttpConnection) Connector.open(url, Connector.READ, true);

Here I'm creating a read only connection (by passing the Connector.READ argument), which should be fine because I don't want to send any data over the connection. However, on Blackberry OS version 4.5 creating a read-only HTTP connection will result in the "not writeable" error, even if you don't explicitly try writing to the connection.

The simple fix is to create the connection with both read and write access:

connection = (HttpConnection) Connector.open(url, Connector.READ_WRITE, true);
Posted on 16 Dec 2008
If you enjoyed reading this post you might want to follow @coderholic on twitter or browse though the full blog archive.