-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The context
in the writeBuffer
function of NettyIoSession
is throwing a null pointer exception.
#587
Comments
Sorry, this is not actionable. The description is too vague. Provide full stack traces (as text, not screenshots!), and explain how to reproduce the problem. I can only guess that it might be some write on an already closed channel. |
exceptionCaught(ServerSessionImpl[deploy@/xx.xx.xx.xx:38684])[state=Opened] NullPointerException: Cannot invoke "io.netty.channel.ChannelHandlerContext.newPromise()" because "this.context" is null |
Provide the full server log. I need to see what happened before that. Ideally you'd also have a backtrace for this exception. Maybe run your server with debug logging. What exactly was the client doing? |
The client initiates createPortForwardingR using jsch, and then another jsch accesses the R channel through createPortForwardingL, which triggers this null problem. |
Additionally, there are some error logs like this: |
Please provide full Java code to reproduce this problem. |
The process is quite complex, so I'll describe it in words. Let's assume: Client IP: 10.0.0.1, Server IP: 192.168.0.1. The client establishes a local port mapping from port 22 to remote port 1111 using jsch. By accessing 127.0.0.1:1111 from the server (192.168.0.1), we can access the client's SSH. Then, on the server, we use jsch to create a local port mapping from server port 2222 to the client's port 3333. Accessing 127.0.0.1:2222 on the server would reach port 3333 on the client, at which point an exception will be reported. |
What is listening on 10.0.0.1:3333? And given that the server seems to be an Apache MINA sshd server, why is JSch being used to create this second tunnel? I also don't see what the first remote forward has to do with this failure in the second tunnel. The two tunnels seem to be unrelated. It should be possible to mock your setup all on one machine and package it as some Java code. I need to be able to reproduce the problem; otherwise any changes we might make would be shots in the dark. We could just code around this NullPointerException, but without knowing why exactly it occurs in the first place and no regression tests we won't really have solved anything. The interesting question here is "why is the context null?". Probably the answer is "because the channel is already closed", and then the next interesting question is "why is the channel closed?". Once we know that, we can decide how to fix this. If the channel is rightly closed, then just coding around the NullPointerException might be a valid solution. If the channel should not be closed at all, then there is some other problem that needs to fixed. To answer these questions I need to have a reproducible case. |
jsch is a method used on another system and cannot be changed. It just uses mina-sshd's SSH tunnel to complete tasks. |
Only forwarding the SSH protocol port and sending a non-SSH protocol request (such as HTTP) will result in an error. |
The following check has been added to the writeBuffer of NettyIoSession, and it is currently functioning normally: if (context == null) { |
I'm not surprised. I do not understand what exactly you are doing, but the whole description so far sounds like some setup bug. Maybe you're not connecting ports the way you actually intended, and end up writing the wrong stuff to the wrong port. Without seeing full code that reproduces the problem there is no way we could help. BTW, the "fix"
is not correct; the |
If a write occurs on an already closed channel, an NPE might occur. Handle this case by setting a ChannelClosedException on the returned future. This prevents the NPE, but other code may still issue other exceptions if a write on a closed channel occurs. Bug: #587
Version
2.13.2
Bug description
Triggering the port after a successful access forwarding.
Actual behavior
The R connection is directly disconnected.
Expected behavior
I hope to fix this issue.
Relevant log output
No response
Other information
No response
The text was updated successfully, but these errors were encountered: