[ 
https://issues.apache.org/jira/browse/SSHD-1033?focusedWorklogId=458859&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-458859
 ]

ASF GitHub Bot logged work on SSHD-1033:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Jul/20 18:18
            Start Date: 14/Jul/20 18:18
    Worklog Time Spent: 10m 
      Work Description: gnodet commented on pull request #141:
URL: https://github.com/apache/mina-sshd/pull/141#issuecomment-658335366


   I would like a proper unit test for that.  I've investigated the issue and 
wrote one, so it should be included in this PR too.  I'll provide a link 
tomorrow.  However, I spent a bit of time looking at the issue and I haven't 
yet understood what the exact problem is and why using two acceptors solves the 
problem.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 458859)
    Time Spent: 2h 40m  (was: 2.5h)

> Unable to use DynamicPortForwarding + LocalPortForwarding
> ---------------------------------------------------------
>
>                 Key: SSHD-1033
>                 URL: https://issues.apache.org/jira/browse/SSHD-1033
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 2.5.1
>            Reporter: Guillermo Grandes
>            Priority: Major
>              Labels: easyfix, pull-request-available, ready-to-commit
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> This is the error running LocalForwarder + DynamicForwarder:
> {code:none}
> [sshd-SshClient[457e2f02]-nio2-thread-6] WARN 
> org.apache.sshd.common.forward.DefaultForwardingFilter - 
> sessionCreated(Nio2Session[local=/127.0.0.1:8000, 
> remote=/127.0.0.1:57657])[local=/127.0.0.1:8000, remote=null] cannot locate 
> original local entry for accepted=/127.0.0.1:8000
> [sshd-SshClient[457e2f02]-nio2-thread-2] WARN 
> org.apache.sshd.client.channel.ClientChannelPendingMessagesQueue - 
> operationComplete(ClientChannelPendingMessagesQueue[channel=TcpipClientChannel[id=1,
>  recipient=-1]-ClientSessionImpl[testuser@/192.168.x.x:22], open=false]) 
> SshChannelOpenException[open failed] signaled
> [sshd-SshClient[457e2f02]-nio2-thread-2] WARN 
> org.apache.sshd.common.forward.DefaultForwardingFilter - Failed 
> (SshChannelOpenException) to open channel for 
> session=Nio2Session[local=/127.0.0.1:8000, remote=/127.0.0.1:57657]: open 
> failed
> {code}
> This is the code to reproduce.
>  * When testLocal = true, testDynamic = true; dynamic fail.
>  * if the order of test are inverted, fail the local instead of dynamic.
>  * if one test is false, the other works well.
> {code:java}
> import java.io.BufferedReader;
> import java.io.IOException;
> import java.io.InputStreamReader;
> import java.net.HttpURLConnection;
> import java.net.InetSocketAddress;
> import java.net.Proxy;
> import java.net.URL;
> import org.apache.sshd.client.SshClient;
> import org.apache.sshd.client.future.ConnectFuture;
> import org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier;
> import org.apache.sshd.client.session.ClientSession;
> import org.apache.sshd.client.session.forward.DynamicPortForwardingTracker;
> import org.apache.sshd.client.session.forward.ExplicitPortForwardingTracker;
> import org.apache.sshd.common.util.net.SshdSocketAddress;
> public class SSHClient {
>       public static void test(final String username, final String password, 
> final String host, final int port)
>                       throws IOException {
>               boolean testLocal = true, testDynamic = true;
>               try (SshClient client = SshClient.setUpDefaultClient()) {
>                       
> client.setServerKeyVerifier(AcceptAllServerKeyVerifier.INSTANCE);
>                       client.start();
>                       try {
>                               ConnectFuture connect = 
> client.connect(username, host, port);
>                               connect.await(10000);
>                               ClientSession session = 
> connect.getClientSession();
>                               session.addPasswordIdentity(password);
>                               session.auth().verify(10000);
>                               if (testLocal) {
>                                       System.out.println("================== 
> Local ==================");
>                                       ExplicitPortForwardingTracker 
> localTracker = session.createLocalPortForwardingTracker(
>                                                       new 
> SshdSocketAddress("localhost", 8082),
>                                                       new 
> SshdSocketAddress("test.javastack.org", 80));
>                                       sleep(1000);
>                                       
> System.out.println("LocalPortForwarding: " //
>                                                       + 
> localTracker.getLocalAddress() + " -> " //
>                                                       + 
> localTracker.getRemoteAddress());
>                                       SshdSocketAddress localSocketAddress = 
> localTracker.getLocalAddress();
>                                       if (localSocketAddress != null) {
>                                               Proxy proxy = new 
> Proxy(Proxy.Type.HTTP,
>                                                               new 
> InetSocketAddress(localSocketAddress.getHostName(), //
>                                                                               
> localSocketAddress.getPort()));
>                                               testRemoteURL(proxy);
>                                       }
>                               }
>                               if (testDynamic) {
>                                       System.out.println("================== 
> Dynamic ==================");
>                                       DynamicPortForwardingTracker 
> dynamicTracker = session
>                                                       
> .createDynamicPortForwardingTracker(new SshdSocketAddress("localhost", 8000));
>                                       sleep(1000);
>                                       
> System.out.println("DynamicPortForwarding: " //
>                                                       + 
> dynamicTracker.getLocalAddress());
>                                       SshdSocketAddress dynamicSocketAddress 
> = dynamicTracker.getLocalAddress();
>                                       if (dynamicSocketAddress != null) {
>                                               Proxy proxy = new 
> Proxy(Proxy.Type.SOCKS,
>                                                               new 
> InetSocketAddress(dynamicSocketAddress.getHostName(), //
>                                                                               
> dynamicSocketAddress.getPort()));
>                                               testRemoteURL(proxy);
>                                       }
>                               }
>                               // @see 
> org.apache.sshd.common.forward.DefaultForwardingFilter#sessionCreated
>                               sleep(1000);
>                       } finally {
>                               client.stop();
>                       }
>               }
>       }
>       private static final void sleep(final long t) {
>               try {
>                       Thread.sleep(t);
>               } catch (Exception ign) {
>               }
>       }
>       private static final void testRemoteURL(final Proxy proxy) throws 
> IOException {
>               HttpURLConnection connection = (HttpURLConnection) new 
> URL("http://test.javastack.org/";)
>                               .openConnection(proxy);
>               System.out.println("Get URL: " + connection.getURL());
>               try {
>                       BufferedReader in = new BufferedReader(new 
> InputStreamReader(connection.getInputStream()));
>                       System.out.println("Response from server:");
>                       String inputLine;
>                       while ((inputLine = in.readLine()) != null) {
>                               System.out.println(inputLine);
>                       }
>                       in.close();
>               } catch (Exception e) {
>                       System.out.println("Failed: " + e);
>               }
>       }
> }
> {code}
> {code:xml}
> <!-- dependencies used --->
> <dependency>
>   <groupId>org.apache.sshd</groupId>
>   <artifactId>sshd-core</artifactId>
>   <version>2.5.1</version>
> </dependency>
> <dependency>
>   <groupId>org.apache.mina</groupId>
>   <artifactId>mina-core</artifactId>
>   <version>2.1.3</version>
> </dependency>
> <dependency>
>   <groupId>org.slf4j</groupId>
>   <artifactId>slf4j-api</artifactId>
>   <version>1.7.30</version>
> </dependency>
> <dependency>
>   <groupId>org.slf4j</groupId>
>   <artifactId>slf4j-simple</artifactId>
>   <version>1.7.30</version>
> </dependency>
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to