Sunday, October 25, 2009

Port 80 may not be a clean path

If you want to host a socket based application on internet, port 80 may not be a clean path to be picked.

A socket based application could be used when application creates a socket and communicates using custom data format like xml and delimited texts.A chat application is a example of socket application. There is a need for continous open connection which will flow chat text to client from server.

Generally client application which wants to do socket communication can rely on technique of http tunneling where a get request is made to a web server and once the socket is opened custom data fromats could be exchanged.

The problem faced here is which port should be selected for hosting chat server.
Selecting port 80 will work in 95 percent of cases and 5 percent of users might face any of problems mentioned ahead.

Request/Reponse: An ISP may route all the requests received from port 80 through proxy server. Proxy server works on request response basis, which means once request is received and forwarded to server and server has started responding, no more request can be received from client on same request connection. So the upstream data or the outbound communication on the client system may not work or hang.

Buffer data: An ISP proxy may buffer given number of bytes received from server and then flow the data to client. This may be done for caching at proxy level. It can also be used to detect if the response is any virus file. However, as per my knowledge hardly any ISPs scan for virus data.In this case inbound link may hand till configured bytes are read.

Proxy Load Balance: Some ISPs may route each request received from client on a load balanced proxy servers. This will cause each request to get different IP. To experience this you can visit and check if your IP address is changing on every request. Try it 5/6 times to ensure it. This may affect those services which are using source ip for some kind of processing on server.

Header modification: When the data is routed through proxy servers at ISP, there are chances that the proxy server may add some additional headers on your reponse. If your application is not tolerant then you may have hard time solving this issue.
Some spyware installed on clients system mostly monitor request on port 80 and may tamper with request response headers.

Antivirus,Firewall,Spyware: However these are client end configurations, if may also affect socket communication. The application executables which are making socket communications should be added in antivirus and firewall exceptions.
Spyware are nasty to the extent of discarding application headers and putting their own headers. So avoid sending application data in http response headers. Your http response headers may not reach client system or may be manipulated.

Choosing a non 80 path may save you from above problems. If all your clients are using direct internet connection you may easily use non 80 port. However if you have users sitting in corporate offices surfing internet thorugh corporate proxy server then selecting non 80 path may be difficult.

This blog entry also to some extent explains how ISPs work internally. If you want ensure that your application works with with most ISPs do test you application with atleast 7-8 proxy servers before going on internet.