This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 207337 - com.jcraft.jsch.JSchException: socket is not established
Summary: com.jcraft.jsch.JSchException: socket is not established
Status: RESOLVED WORKSFORME
Alias: None
Product: versioncontrol
Classification: Unclassified
Component: Git (show other bugs)
Version: 7.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Ondrej Vrabec
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-16 10:55 UTC by almson
Modified: 2012-01-17 09:24 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description almson 2012-01-16 10:55:21 UTC
In trying to connect to Beanstalk, I often (but not always), receive a Cannot connect message. Looking through the netbeans logs I see the following exception:

INFO [org.netbeans.modules.git.ui.repository.remote.SelectUriStep]: Cannot connect to git@almson.beanstalkapp.com:/syncwords-server.git
com.jcraft.jsch.JSchException: socket is not established
	at com.jcraft.jsch.Util.createSocket(Util.java:386)
	at com.jcraft.jsch.Session.connect(Session.java:186)
	at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:128)
Caused: org.eclipse.jgit.errors.TransportException: git@almson.beanstalkapp.com:/syncwords-server.git: socket is not established
	at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:138)
	at org.netbeans.libs.git.jgit.JGitSshSessionFactory.getSession(JGitSshSessionFactory.java:105)
	at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
	at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
	at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
	at org.netbeans.libs.git.jgit.commands.ListRemoteObjectsCommand.run(ListRemoteObjectsCommand.java:73)
Caused: org.netbeans.libs.git.GitException$AuthorizationException: git@almson.beanstalkapp.com:/syncwords-server.git: socket is not established
	at org.netbeans.libs.git.jgit.commands.TransportCommand.handleException(TransportCommand.java:171)
	at org.netbeans.libs.git.jgit.commands.ListRemoteObjectsCommand.run(ListRemoteObjectsCommand.java:86)
	at org.netbeans.libs.git.jgit.commands.GitCommand.execute(GitCommand.java:68)
	at org.netbeans.libs.git.jgit.JGitClient.listRemoteTags(JGitClient.java:423)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.netbeans.modules.git.client.GitClientInvocationHandler.invokeClientMethod(GitClientInvocationHandler.java:280)
......

Looking at the JSch code (http://www.docjar.org/html/api/com/jcraft/jsch/Util.java.html) I can conclude the only possible cause is an InterruptedException during the join(). (It can't be a timeout, since there is no 'timeout: ' string in the message, and it probably isn't an exception in new Socket() because there's no additional text either.) I am in Ukraine, so my latency can be a bit high. I assume there's some secondary timeout in org.openide.util.RequestProcessor$Task that is shorter than necessary.

Possible workaround: call jsch.Util.createSocket() with a timeout of 0
Better workaround: rewrite the jsch.Util.createSocket() function to just use Socket.connect(endpoint, timeout) instead of the hairbrained threaded scheme (which they used to be compatible with JDK <1.4)
Comment 1 almson 2012-01-16 11:06:40 UTC
My latency to Beanstalk right now is 130ms. In the evening it can be more. The "connecting" progress bar goes for a few seconds (maybe 3?) before producing the error messages.
Comment 2 Ondrej Vrabec 2012-01-16 12:52:41 UTC
Yes, there is a timeout set up for an ssh connection, but that is 45 seconds (much more than your 130ms).
> Possible workaround: call jsch.Util.createSocket() with a timeout of 0
If we used 0 for the timeout than the connection attempt will ignore any external interrupt and clicking on Cancel/Stop button in the IDE will do nothing.
> Better workaround: rewrite the jsch.Util.createSocket() function to just use
> Socket.connect(endpoint, timeout) instead of the hairbrained threaded scheme
> (which they used to be compatible with JDK <1.4)
Since this call is done inside the jsch library, i can not help you with that. You should file a bug on the JSCh project on http://sourceforge.net/projects/jsch/

> I can conclude the only possible cause is an InterruptedException during the join()
Yes, that seems so, but i have no idea who calls the interrupt(). Because the ssh connection generally works, i cannot continue without of your help. It would be great if you could debug the code and try to find the source of the interrupt.

One more question, are you behind proxy or not? SSH cannot be tunneled through proxy via the JSCh we're using.
Comment 3 almson 2012-01-16 14:22:30 UTC
I am not behind a proxy. Netbeans does sometimes connect.

It certainly does not wait 45s. This is a real problem, because I cannot use the Netbeans Git to do remote pushes/pulls/clones. (Well, I just use another Git client, but that's besides the point.) My latency is not extreme or unusual, so it is a common problem for others besides me.

You can emulate high network latency on your end with NetLimiter (Windows), Dummynet (OSX, FreeBSD, Windows), or something else. I don't know enough to set up a debugging environment for a Netbeans plugin, but you can send me a modified code that has extra logging information (to, eg, catch the message and context of the InterruptedException).
Comment 4 Ondrej Vrabec 2012-01-17 09:24:56 UTC
NB development builds for 7.2 now use jsch in version 0.1.45, where a session is established differently and will probably solve your problem. See the sources at http://sourceforge.net/projects/jsch/files/jsch/0.1.45/
Download the latest development build from [1], install and start it, do not import any settings, open your project and try the pull/push/fetch wizard. If you experience any error, attach the messages log [2] with the error.

[1] - http://bits.netbeans.org/download/trunk/nightly/latest/
[2] - probably at ~/.netbeans/dev/var/log/messages.log