08-15-2010 04:28 PM - edited 08-16-2010 09:42 AM
I am attempting to establish a TCP connection via BIS-B and am running into some problems. Before describing the situation, I'd just like to clarify:
- We are members of the BlackBerry Alliance program;
- We have been granted permission to use BIS-B;
- The application is now working under direct TCP; and
- The sample application provided with the BIS-B information package runs fine on the device.
So, it appears the device has BIS-B access and that our application should be able to connect through BIS-B without difficulty. I previously forwarded this question to the Alliance but was directed here for support, so I'll outline the issue without mentioning any aspects of BIS-B covered under the NDA.
Here's the situation:
The connection string I am using to establish a TCP socket to our server program from the device is:
IP_ADDRESS is the IP of the server program the connection is being made to;
TCP_SERVER_PORT is the TCP port; and
BIS_B_CONNECTION_STRING is the connection string provided for BIS-B access.
As with Direct TCP, the SocketConnection object is being created via:
Where connString is the connection string noted above. Once the connector has been created, separate threads for sending and receiving on the socket are started.
To connect to the server, a packet of 76 bytes of data is written to the socket with OutputStream.write(byte b, int off, int len) and flushed with OutputStream.flush(). The data is received on the server without a problem and a 32-byte ACK packet is sent back from the server to the device in response.
Here is where the problem appears: The client application on the device never receives the data sent from the server. Although the socket has been established and data can be sent over that socket from the device to the server, not a single byte sent from the server to the device is received by the device. In contrast, when using direct TCP to establish the socket, data is transmitted between the server and device without a problem.
This leads me to conclude that one or both of the following are happening:
1) I am not creating the socket correctly for a BIS-B connection.
The examples provided in the BIS-B documentation are all for HTTP connections and no demonstration code is provided to show how a TCP socket should be created. It is entirely possible there is a minor adjustment required to the BIS-B connection string of which I am unaware or that I am creating the socket incorrectly.
2) My BlackBerry service provider has incorrectly configured their BIS-B network connections.
My device is connected to TELUS and the situation I'm facing sounds much like that described by this fellow back in 2008:
Since the problem occurs when data is transmitted from the server to the device, it seems possible that the device IP addresses are not being properly NATted to the public address the server is transmitting data to. I have called TELUS's DNA folks to confirm BIS-B service is available but (as the linked post describes), that does not necessarily eliminate the possibility of a mis-configured NAT.
So, my questions to you folks are:
- If a TCP server program is receiving data from a device via BIS-B, does that indicate the BIS-B socket has been correctly established (and so the problem receiving data server-to-device is carrier or device-specific)?
- Am I doing something obviously incorrect in establishing a TCP socket via BIS-B?
- Is there an additional parameter required in the connection string (beyond those provided for the BIS-B HTTP connection example) when creating a TCP socket via BIS-B?
Solved! Go to Solution.
08-16-2010 11:34 AM
When searching for the BIS-B connection string online, I've found that a few people are recommending use of the ConnectionUID attribute in the BIS-B connection string, with the Uid chosen being that from the BIBS IPPP entry in the service book. However, that attribute is not mentioned in the BIS-B documentation provided by the Alliance (which only gives examples for HTTP connections via BIS-B).
Is the ConnectionUID element required to establish a TCP socket connection via BIS-B which can write data from server-to-device, or is my problem due to a mis-configuration of my BlackBerry carrier's network (since sending data device-to-server via BIS-B has not been a problem)?
08-16-2010 12:19 PM
I would recommend using the information supplied by RIM, I believe there is a certain amount of mis-information spread about BIS-B.
What ports are you trying to use?
08-16-2010 12:39 PM
The server is running on TCP port 8052 (so, within RIM's noted limits for BIS-B).
I have pored over the information provided by RIM, but there are no examples given for a TCP socket connection via BIS-B (only HTTP). I have assumed that a BIS-B TCP socket connection is handled exactly as an HTTP connection is, with the BIS-B connection string replacing the ';deviceside=true' normally used for a direct TCP connection.
When using that connection string I am able to both establish the socket and send data from device to server. However, sending data from the server to the device results in no data received on the device.
From the information I have available it appears I am creating the BIS-B TCP socket correctly, so I'm stumped as to what could be keeping the device from receiving data from the server.
08-17-2010 10:53 AM
The problem's cause turned out to be the use of InputStream.available() to check for the quantity of available bytes incoming on the socket.
Although InputStream.available() worked fine for direct TCP (at least for CDMA networks), the method consistently returned a value of 0 when receiving bytes over BIS-B. As a result, it appeared the server-to-device side of the TCP socket was not receiving data when in fact the data was available for reading. Using InputStream.read() to instead block and read each byte as it was received on the socket resolved the issue. Given that inconsistent functionality, I would recommend avoiding use of InputStream.available().
For anyone searching on the creation of BIS-B TCP sockets in the future, here an answer to my original question:
The connection string to use when creating a BIS-B TCP socket is the same as that shown in RIM's code examples for an HTTP connection (the code examples and your BIS-B connection string are received once approval has been given to use BIS-B under the Alliance program).
For example, if your connection string for creating a direct TCP socket would be:
where IP_ADDRESS is the IP address of your TCP server program and TCP_PORT is the network port on which traffic is received by the server, you need only replace the ';deviceside=true' part of your connection string with the string provided to you by RIM for your BIS-B connection. The resulting string would then be used in the creation of a standard TCP socket, such as the following:
where connString is your "socket://..." connection string.