• Post Reply Bookmark Topic Watch Topic
  • New Topic

Socket connection through a proxy

 
Atulya Mahajan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to open a socket to an address out of the company network and thus firewalled.

I tried the following but it doesnt seem to do anything.
I see the proxy object gets created, but the when the socket tries to connect, it just seems to get blocked.




Is there anything else i need to do to make it work?

Thanks Much
Atulya
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you getting an exception? I think that a timeout of 1 second is probably a little optimistic.
 
Atulya Mahajan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont get any exception. It just gets blocked and sits doing nothing.

I found another approach on going through a proxy and tried the following VM arguments
-Dhttp.proxyHost=webproxy.blah.com -Dhttp.proxyPort=80

and just a normal socket call, with no Proxy used in the code. By doing this, i am able to connect to a machine that is not firewalled (the proxy code wouldnt even connect to that machine), but with my destination machine i get
"java.net.SocketTimeoutException: connect timed out" ( I increased the timeout to 5 seconds btw)

any comments on this? Is there any way to find out if these connections are indeed going through the proxy?


What is the standard way of doing this? I couldnt find much documentation on using proxies.
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Atulya Mahajan:
I dont get any exception. It just gets blocked and sits doing nothing.
. . .
i get "java.net.SocketTimeoutException: connect timed out" ( I increased the timeout to 5 seconds btw)


Do you get an exception or not?
How long does it take to access the same resource with a browser? More than 5 seconds?
 
Atulya Mahajan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am talking about two different approaches:

1. Create proxy object and pass to socket constructor.

This gets blocked. I get no exception

2. Create socket as usual.
Pass in http.proxyHost and http.proxyPort JVM arguments to the application.

This method works with a non firewalled machine, but with the machine outside our network that i want to connect to, i get the timeout. I tried even a 50 sec timeout. It certainly doesnt take that long to connect to this machine.

Thanks
 
Irfan Md
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Atulya Mahajan,

I'm also facing the same issue. Did you get any solution for this. If so kindly let me know what you had done to set the proxy for Socket.

Thanks
Irfan
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Irfan Md",
Please check your private messages regarding an important administrative matter.
-Ben
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!