Hi! I've the same problem and i don't be able to connect to my application
server through the proxy.
Here there's the code that i've use:
Proxy proxyServer = new Proxy(Proxy.Type.SOCKS, new
InetSocketAddress("192.168.2.250", 3128));
IoConnector connector = new SocketConnector(proxyServer);
IoConnectorConfig config = new SocketConnectorConfig();
config.setThreadModel(ThreadModel.MANUAL);
...
...sorry for my terrible english :-/
JIRA [EMAIL PROTECTED] wrote:
>
> [
> http://issues.apache.org/jira/browse/DIRMINA-223?page=comments#action_12432728
> ]
>
> Trustin Lee commented on DIRMINA-223:
> -------------------------------------
>
> I found your patch won't work. SocketChannel.open() is a static method,
> and therefore, socket.getChannel().open() doesn't have effect other than
> resource leakage due to an extra socket creation.
>
> NIO specification says that socket.getChannel() will return *null* unless
> the socket is created via SocketChannel.open().
>
> Are you sure that your patch is really working with a Proxy?
>
>> Addition of SocketConnector method to handle socks proxies.
>> -----------------------------------------------------------
>>
>> Key: DIRMINA-223
>> URL: http://issues.apache.org/jira/browse/DIRMINA-223
>> Project: Directory MINA
>> Issue Type: Improvement
>> Affects Versions: 0.9.4
>> Environment: All platforms
>> Reporter: John Preston
>>
>> When using MINA to to establish a SocketConnector behind a firewall it is
>> necessary to specify socks proxie to use. The SocketConnector can be
>> ammended as follows: (svn diff)
>> Index:
>> core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
>> ===================================================================
>> ---
>> core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
>> (revision 415629)
>> +++
>> core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
>> (working copy)
>> @@ -21,6 +21,7 @@
>> import java.io.IOException;
>> import java.net.ConnectException;
>> import java.net.InetSocketAddress;
>> +import java.net.Proxy;
>> import java.net.SocketAddress;
>> import java.nio.channels.SelectionKey;
>> import java.nio.channels.Selector;
>> @@ -61,6 +62,7 @@
>> private final Set managedSessions = Collections.synchronizedSet( new
>> HashSet() );
>> private final SocketIoProcessor[] ioProcessors;
>> private final int processorCount;
>> + private final Proxy socketProxy;
>>
>> /**
>> * @noinspection FieldAccessedSynchronizedAndUnsynchronized
>> @@ -73,9 +75,17 @@
>> /**
>> * Create a connector with a single processing thread
>> */
>> + public SocketConnector(Proxy proxy)
>> + {
>> + this( 1, proxy );
>> + }
>> +
>> + /**
>> + * Create a connector with a single processing thread
>> + */
>> public SocketConnector()
>> {
>> - this( 1 );
>> + this( 1, Proxy.NO_PROXY );
>> }
>>
>> /**
>> @@ -83,7 +93,7 @@
>> *
>> * @param processorCount Number of processing threads
>> */
>> - public SocketConnector( int processorCount )
>> + public SocketConnector( int processorCount, Proxy proxy )
>> {
>> if( processorCount < 1 )
>> {
>> @@ -91,6 +101,7 @@
>> }
>>
>> this.processorCount = processorCount;
>> + this.socketProxy = proxy == null ? Proxy.NO_PROXY : proxy;
>> ioProcessors = new SocketIoProcessor[processorCount];
>>
>> for( int i = 0; i < processorCount; i++ )
>> @@ -153,11 +164,12 @@
>> boolean success = false;
>> try
>> {
>> - ch = SocketChannel.open();
>> - ch.socket().setReuseAddress( true );
>> + Socket s = new Socket(socketProxy);
>> + s.setReuseAddress( true );
>> + ch = s.getChannel().open();
>> if( localAddress != null )
>> {
>> - ch.socket().bind( localAddress );
>> + s.bind( localAddress );
>> }
>>
>> ch.configureBlocking( false );
>> @@ -475,4 +487,4 @@
>> this.config = config;
>> }
>> }
>> -}
>> \ No newline at end of file
>> +}
>
> --
> This message is automatically generated by JIRA.
> -
> If you think it was sent incorrectly contact one of the administrators:
> http://issues.apache.org/jira/secure/Administrators.jspa
> -
> For more information on JIRA, see: http://www.atlassian.com/software/jira
>
>
>
>
>
--
View this message in context:
http://www.nabble.com/-jira--Created%3A-%28DIRMINA-223%29-Addition-of-SocketConnector-method-to-handle-socks-proxies.-tf2697070s16868.html#a12251387
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.