Friday, March 20, 2009

Java Serialization fails on Slow Network

Software like humans have behaviour, and more we use one we come to know about its behaviour..A Socket and ServerSocket connection was abruptly throwing EOFException in a slower network of 2 mbps but the same works without a single problem on the 100 mbps network. Apparently, Java was not throwing the timeout exception.

This problem was not coming always. The data flow of byte array was flowing properly without any problem in most of the cases.. But all of sudden, some of the packets seemed to be dropped.. As the receiving program did not get the complete bytes it was not able to construct a complete object using deserialization.

This whole problem embedded inside full fledged application makes it difficult to locate. DataOutputStream.writeUTF and DataInputStream.readUTF seams to fail.

In this process some tools came quite handy. AutoIT was a good tool for simulating user interface test cases. Its very easy to write script for making mouse clicks, keypress and window activation. I am sure its going to be useful to me in many of future projects. Another tool was Speed Limiter. When we do load testing in 100 mbps network our application works differently then over slower network. This makes it important to do load testing over slower networks like 56 kbps(Dial up), 1mbps, 2 mbps(BroadBand) networks. The timeouts, buffer size, queue size should be tuned for these network connections. We can run Speed Limiter on the Server system, on the port on which server was going to run and run the server on different port. Then we can mention the port mapping in Speed Limiter. You can select different speeds at which you want to do simulation. Only feature i missed in this tool was jerks or spike. In real network the connection gets stuck for some seconds and then starts again. This cannot be simulated here.

Coming back to core problem, i thought that there might be some software component in network like Antivirus which may be dropping/blocking some packets. But it was not the case. The problem was with the connection timeout. It the connection timeout was set to 10000 and above using Socket.setsotimeout function the problem gets solved..

So all that appeared to be a serialization problem was actually a timeout problem.

There are other serialization problems which i am facing like a long value being serialized over network gets divided by 32 on the receiving end. Then in one more case a String if has length more than 128 bytes gives StreamFormatException when serialized. I will update about same once i resolve the issues..

Wednesday, February 4, 2009

Windows Mobile Internet Connection

You will find many resources in internet which lets you use connect your windows mobile phone to your laptop using bluetooth or USB and surf internet. For those who are still living under the rocks, i would mention the steps again.
1.In mobile->Enable bluetooth on your mobile such that your device becomes visible to other divices.
2.In mobile->Using ActiveSync connect to your laptop. Put key if asked for.
3.In mobile->Start Programs->Start Internet Sharing with Connection as Bluetooth.
3.From Desktop go to start-> Connect to->Set up connection or network->Connect to bluetooth personal area network->select your mobile device-> Click on connect.

You are ready to browse internet.To confirm you can now give ipconfig command on your command prompt.Your system has got a IP now. But this is not for which i am writing this entry.

This weekend i had a peculiar requirement. I needed high speed internet connection on my mobile device. Unfortunately i did not have any Wi-Fi support on my mobile. So i needed to connect my mobile to my laptop and use laptops internet connection. I searched the net to only find that every one had this query, but no solution.
So i decided to break the nut myself.

Here are the steps i consolidated.
1. In Laptop->Download any proxy server on your system. I had downloaded Winproxy free version.
2. In Laptop->Start the proxy server. Note the port.
3. In mobile->Start Settings-> Connections->Advance-> Select Network.
Set Both the connections as My Work Network.
4. In mobile->Start Settings-> Connections->Task->Setup Proxy Server-> Check Internet and Proxy Checkboxes->
Enter the IP of your desktop where you are running the proxy server.
Click Advance and ensure that the http and socks port is the one on which your proxy server is listening on.
5. In mobile->Active Sync->Connect using Bluetooth.
6. In mobile->Start Internet Explorer and browse.

This will allow you to use the reverse or opposite internet connection on your windows mobile using bluetooth. If you are already having a internet connection and geting additional connection using above method then you can restart laptop after disconnecting the existing connection.

With this entry i am having my first taste of blooging. Hope we have a good time in future..