[
https://issues.apache.org/jira/browse/SSHD-1055?focusedWorklogId=781533&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-781533
]
ASF GitHub Bot logged work on SSHD-1055:
----------------------------------------
Author: ASF GitHub Bot
Created on: 15/Jun/22 08:33
Start Date: 15/Jun/22 08:33
Worklog Time Spent: 10m
Work Description: tomaswolf commented on PR #227:
URL: https://github.com/apache/mina-sshd/pull/227#issuecomment-1156165890
All right. The MINA problems are resolved now. It looks as if this
shutdownOutputStream() stuff was never tested with MINA at all; when SSHD-902
was done, the core tests didn't even run in the CI build with MINA.
It now turns out that MINA doesn't like it at all when we fiddle around with
the socket directly. My solution for MINA is to just close the session once all
pending writes have been written. That's doable via standard MINA API
(IoSession.closeOnFlush()), doesn't confuse the MINA select loop, doesn't cause
slow-down as observed in the previous versions of this PR, and makes the new
Sshd1055Test pass without causing problems for the other tests.
Note that the new Sshd1055Test is disabled in the maven build because it
uses testcontainers, and setting up testcontainers doesn't work well with the
re-useable test JAR due to classpath problems (test resources are not found).
I have run that new test manually with MINA and Netty, and it passes.
With Nio2, it is run in the CI build.
Issue Time Tracking
-------------------
Worklog Id: (was: 781533)
Time Spent: 1h (was: 50m)
> Remote port forwarding mode does not handle EOF properly
> --------------------------------------------------------
>
> Key: SSHD-1055
> URL: https://issues.apache.org/jira/browse/SSHD-1055
> Project: MINA SSHD
> Issue Type: Bug
> Affects Versions: 2.5.1
> Reporter: Feng Jiajie
> Assignee: Thomas Wolf
> Priority: Major
> Time Spent: 1h
> Remaining Estimate: 0h
>
> I want to call the remote server's gRPC service locally through an SSH
> tunnel.
> MyApp -> MINA SSHD -> \{Internet} -> gRPC Server
> It works just fine with OpenSSH, but there is a small problem(no problems
> with core functions, only in unusual circumstances) with Mina SSHD.
> I think the problem is Mina SSHD's handling of EOF.
> Here is the example:
> Step 1. Start a gRPC server:
> Because we only need a gRPC server to reproduce the problem, so I write a
> simple version without any service:
> {code:java}
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-netty-shaded</artifactId>
> <version>1.27.2</version>
> </dependency>
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-protobuf</artifactId>
> <version>1.27.2</version>
> </dependency>
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-stub</artifactId>
> <version>1.27.2</version>
> </dependency>
> {code}
> main:
> {code:java}
> import io.grpc.Server;
> import io.grpc.ServerBuilder;
> public class EmptyGrpcServer {
> public static void main(String[] args) throws Exception {
> Server server = ServerBuilder.forPort(23645).build().start();
> server.awaitTermination();
> }
> }
> {code}
> Full example can be fond here:
> [https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java]
>
> Step 2. Start a MINA SSHD server:
> {code:java}
> import org.apache.sshd.server.SshServer;
> import org.apache.sshd.server.forward.AcceptAllForwardingFilter;
> import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
> import java.nio.file.Paths;
> public class Example1 {
> public static void main(String[] args) throws Exception {
> SshServer sshd = SshServer.setUpDefaultServer();
> sshd.setPort(12133);
> sshd.setKeyPairProvider(new
> SimpleGeneratorHostKeyProvider(Paths.get("/tmp/a.ser")));
> sshd.setPasswordAuthenticator((username, password, session) -> true);
> sshd.setForwardingFilter(AcceptAllForwardingFilter.INSTANCE);
> sshd.start();
> Thread.sleep(10000000);
> }
> }
> {code}
> Step 3. Create a channel using ssh client
> {code:java}
> ssh -o 'ExitOnForwardFailure yes' -vvv -p 12133 -f -x -N -T -R
> 0.0.0.0:0:127.0.0.1:23645 [email protected]
> {code}
> Step 4. Reproduce
> If I connect directly to the gRPC server using curl, cause gRPC using http/2,
> I would get error output like this:
> {code:java}
> $ curl 127.0.0.1:23645
> ���+Unexpected HTTP/1.x request: GET /
> $
> {code}
> Then if I do step 3 with an OpenSSH server, I would get same error output:
> {code:java}
> $ ssh -o 'ExitOnForwardFailure yes' -f -x -N -T -R 0.0.0.0:0:127.0.0.1:23645
> [email protected]
> Allocated port 13525 for remote forward to 127.0.0.1:23645
> $
> $ curl dev.kbyte.cn:13525
> ���+Unexpected HTTP/1.x request: GET /
> $
> {code}
> But when I do step 3 with MINA SSHD, curl would stuck without any output:
> {code:java}
> $ curl 127.0.0.1:55604
> {code}
> I found MINA SSHD had already got and wrote the package with the string
> "Unexpected.HTTP/1.x.request:.GET", and received SSH_MSG_CHANNEL_EOF.
> So I think handleEof should do more? like send SSH_MSG_CHANNEL_EOF to curl?
>
--
This message was sent by Atlassian Jira
(v8.20.7#820007)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]