tags:

views:

1591

answers:

3

I have written a TCP IP socket program which works fine. But my socket program did not work if my server or client is behind proxy. So how to overcome from this type of issue.

Thanks Bapi

+2  A: 

Well there's two issues to consider:

  1. Behind a proxy; and
  2. Behind a firewall.

Firewall tends to be easier: you simply use port 80 (HTTP) or 443 (HTTPS). Proxy is harder because direct network communication tends to be disabled from normal PCs.

This is why you often find people using HTTP and/or SSL as their transport mediums because they bypass these kinds of security issues. You can do push content (with long-lived connections aka Comet techniques) so there's typically no real technical reason not to.

But it's hard to say one way or the other if that's a good idea or not without knowing more about your application and any pertinent requirements.

cletus
Thanks for your helpful information.I need information regarding TCP IP only.My deal was with TCP IP socket programming.
A: 

Depending on the proxy, there may be little that you can do. If the Proxy is designed to block all traffic that it does not directly handle, then you have to either go through the proxy, somehow working with it, or you have to find a way to sneak through the proxy.

For example, many applications are built on top of HTTP precisely because it is commonly allowed through firewalls and is commonly proxy-friendly. Thus, it's a pretty safe way of communicating when you know that you'll be installing the application in environments where proxies may exist.

In your case, it depends on what port(s) your application uses, on whether these ports are commonly handled by a proxy for any existing protocol, on whether or not you're using a standard (commonly known) protocol or have invented your own, and so on.

Is this proxy a transparent proxy? (That is, do web browsers have to be configured to see it, or not?) The kind of proxy it is determines part of how your application needs to work with it. Is the proxy controlled by your organization?

You say you are using port 5018. Just as an experiment, can you try using port 80? Just because you're using port 80 doesn't mean you have to use HTTP. This is worth a try to see if it helps.

Eddie
Thanks Eddie, for your replyI have created a simple socket programming in java.My server runs in US and client in India. I am using port 5018 which is free for my serverSo in this case my socket program did not work.I have tried that program with my colleague in my LAN that program worked fine
Thanks for your helpful information.I need information regarding TCP IP only.My deal was with TCP IP socket programming.
I updated my answer in response to your additional information.
Eddie
+2  A: 

Proxies usually work at the application level, not at the transport level. Here is some information about Java and proxies.

Maurice Perry
Thanks for your helpful information.I need information regarding TCP IP only.My deal was with TCP IP socket programming.
Well that's the problem: TCP/IP is a transport protocol, not an application protocol. The solution actually depends on the kind of proxy that is installed in your environment. If there is a SOCKS proxy, then TCP can go through (see section 2.4 of the page references above)
Maurice Perry
Thanks Maurice Perry,I am unable to get what does Environment means ? whether server side or client side? How to deal with other than SOCKS proxy.Let I am server some other one is client then in which program I have to made change server or client?
Well it can be on the client, on the server, or both. The client (the party that initiates the connection) can be on a local network and can need to go through a proxy to get out on the Internet.
Maurice Perry
The server can itself be on another local network with a firewall, and a reverse-proxy. On the server side, it boils down to a configuration problem, on the client side, you may need to use the socksProxyHost system property.
Maurice Perry
Another thing to consider, is using a tunnel between the client and the server, in which case, the client would initiate the TCP connection on localhost.
Maurice Perry
Thanks Perry,My server do not have any proxy or firewall. Then in this case whether i have to check for proxy level of client? and also how to know proxy level of client? If my client does not use SOCKS proxy in that case what I have to do to get TCP IP socket connection
The best thing to do in this case is to add SOCKS support on the proxy, HTTP tunneling could be an alternative, but this is not very efficient and network admins don't like this kind of stuff. The last thing to consider is using HTTP instead of raw sockets in your application
Maurice Perry
Thanks Perry,I think Proxy setting will be in client side. so how to add SOCKS support on the proxy? Also I have to use TCP IP sockets only. So any solution for this type of problem.
@Maurice Perry: by the way, network-related system properties like `socksProxyHost` often do not get initialized for ordinary Java applications.
dragonfly
@dragonfly: of course not. He would have to take care of that
Maurice Perry
@Perry, I think Proxy setting will be in client side. so how to add SOCKS support on the proxy? Also I have to use TCP IP sockets only. So any solution for this type of problem
This is more of a network admin issue that a programming issue. The network must be configured so that it allows your application to communicate with the server, and there is nothing you can do about it in the application itself.
Maurice Perry