dyw770 opened a new issue, #441:
URL: https://github.com/apache/mina-sshd/issues/441

   ### Version
   
   2.11.0
   
   ### Bug description
   
   ```java
   package cn.dyw.web.jshell.client;
   
   import org.apache.sshd.client.SshClient;
   import org.apache.sshd.client.channel.ClientChannel;
   import org.apache.sshd.client.channel.ClientChannelEvent;
   import org.apache.sshd.client.future.ConnectFuture;
   import org.apache.sshd.client.session.ClientSession;
   import org.apache.sshd.common.future.CancelOption;
   import org.apache.sshd.common.util.io.input.NoCloseInputStream;
   import org.apache.sshd.common.util.io.output.NoCloseOutputStream;
   import org.junit.jupiter.api.Test;
   
   import java.net.InetSocketAddress;
   import java.util.Collections;
   import java.util.concurrent.TimeUnit;
   
   /**
    * @author dyw770
    * @date 2023-11-27
    */
   
   public class SSHDClientTest {
   
       /**
        * Server has no output
        */
       @Test
       public void testSSHDClient() throws Exception {
           SshClient client = SshClient.setUpDefaultClient();
           client.start();
           ConnectFuture connectFuture = client.connect("root", new 
InetSocketAddress("172.16.253.101", 22));
           ClientSession session = connectFuture.verify(1000, TimeUnit.SECONDS, 
CancelOption.CANCEL_ON_TIMEOUT).getSession();
           session.addPasswordIdentity("123456789");
           session.auth().verify(1000, TimeUnit.SECONDS, 
CancelOption.CANCEL_ON_TIMEOUT);
           ClientChannel channel =session.createShellChannel();
           channel.setOut(new NoCloseOutputStream(System.out));
           channel.setRedirectErrorStream(true);
           channel.setIn(new NoCloseInputStream(System.in));
           channel.open().verify(1000, TimeUnit.SECONDS, 
CancelOption.CANCEL_ON_TIMEOUT);
   
           channel.waitFor(Collections.singleton(ClientChannelEvent.CLOSED), 0);
           channel.close();
           session.close();
           client.stop();
       }
   
       /**
        * Normal server output
        */
       public static void main(String[] args) throws Exception {
           SshClient client = SshClient.setUpDefaultClient();
           client.start();
           ConnectFuture connectFuture = client.connect("root", new 
InetSocketAddress("172.16.253.101", 22));
           ClientSession session = connectFuture.verify(1000, TimeUnit.SECONDS, 
CancelOption.CANCEL_ON_TIMEOUT).getSession();
           session.addPasswordIdentity("123456789");
           session.auth().verify(1000, TimeUnit.SECONDS, 
CancelOption.CANCEL_ON_TIMEOUT);
           ClientChannel channel =session.createShellChannel();
           channel.setOut(new NoCloseOutputStream(System.out));
           channel.setRedirectErrorStream(true);
           channel.setIn(new NoCloseInputStream(System.in));
           channel.open().verify(1000, TimeUnit.SECONDS, 
CancelOption.CANCEL_ON_TIMEOUT);
   
           channel.waitFor(Collections.singleton(ClientChannelEvent.CLOSED), 0);
           channel.close();
           session.close();
           client.stop();
       }
   
   }
   
   ```
   The result is shown in the figure
   <img width="2418" alt="image" 
src="https://github.com/apache/mina-sshd/assets/26217571/2085b364-d3c4-450b-b632-c04676f7c8c6";>
   <img width="2453" alt="image" 
src="https://github.com/apache/mina-sshd/assets/26217571/4426c3fa-0849-4e3f-afbc-7ef097ab242b";>
   
   Can you tell me where my mistake lies? 
   Thinks.
   
   ### Actual behavior
   
   Server has no output
   
   ### Expected behavior
   
   Normal server output
   
   ### Relevant log output
   
   _No response_
   
   ### Other information
   
   _No response_


-- 
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.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org

Reply via email to