Fiji from command line crashes when offline

Hey @ctrueden & @frauzufall,

Fiji crashes with sad error messages when the updater tries to run and the machine is offline. Would it be possible to deal with that more silently?

We executed the following command:

fiji --version 

and saw this error popping up:

Thanks! :blue_heart:
Robert

I cannot read the message in the picture, for me this comes up:

[ERROR] Cannot connect to the Internet.
Do you have a network connection?
Are your proxy settings correct?
[ERROR] null
java.net.UnknownHostException: imagej.net
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at java.net.Socket.connect(Socket.java:538)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
	at sun.net.www.http.HttpClient.New(HttpClient.java:339)
	at sun.net.www.http.HttpClient.New(HttpClient.java:357)
	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
	at net.imagej.ui.swing.updater.ImageJUpdater.testNetworkConnection(ImageJUpdater.java:371)
	at net.imagej.ui.swing.updater.ImageJUpdater.errorIfNetworkInaccessible(ImageJUpdater.java:324)
	at net.imagej.ui.swing.updater.ImageJUpdater.run(ImageJUpdater.java:101)
	at org.scijava.command.CommandModule.run(CommandModule.java:199)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
	at org.scijava.thread.DefaultThreadService$3.call(DefaultThreadService.java:238)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

We could stop printing the stack trace, but since there are multiple reasons why the network connection might fail, this can be informative. We could move it to the debug mode.

2 Likes

Hey @frauzufall,

thanks for taking care! The computer was offline. We just wanted to know Fijis version :wink:

Thanks again!

Cheers,
Robert

Sorry, I never tried that, where / how did you execute this command? This does not work for me:

➜  Fiji.app ./ImageJ-linux64 --version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
[WARNING] Ignoring invalid argument: --version
2 Likes

It doesn’t do anything on my machine… I hope @aklemm can reproduce it and post the error message here?

The error occurs without console, when starting normal (updated) Fiji:

[WARNING] Could not determine the IP address of https://imagej.net. Make sure you are connected to a network.
[INFO] Reading available sites from https://imagej.net/
[ERROR] null
java.net.UnknownHostException: imagej.net
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1890)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1885)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1884)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1457)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
	at net.imagej.util.MediaWikiClient.request(MediaWikiClient.java:234)
	at net.imagej.util.MediaWikiClient.query(MediaWikiClient.java:243)
	at net.imagej.util.MediaWikiClient.getPageSource(MediaWikiClient.java:109)
	at net.imagej.updater.util.AvailableSites.getAvailableSites(AvailableSites.java:79)
	at net.imagej.updater.util.AvailableSites.getAvailableSites(AvailableSites.java:69)
	at net.imagej.updater.util.AvailableSites.hasUpdateSiteURLUpdates(AvailableSites.java:271)
	at net.imagej.updater.UpToDate.check(UpToDate.java:114)
	at net.imagej.updater.UpToDate.check(UpToDate.java:86)
	at net.imagej.updater.CheckForUpdates.run(CheckForUpdates.java:63)
	at org.scijava.command.CommandModule.run(CommandModule.java:199)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
	at org.scijava.thread.DefaultThreadService$3.call(DefaultThreadService.java:238)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.UnknownHostException: imagej.net
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
	at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
	at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
	at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
	at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(HttpURLConnection.java:2966)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderFields(HttpsURLConnectionImpl.java:283)
	at net.imagej.util.MediaWikiClient.request(MediaWikiClient.java:223)
	... 17 more
2 Likes

Does it crash? Or just emit a stack trace to the console? If it actually crashes, this is a serious bug.

Relatedly: this opens up a more general question: if an invalid command line flag is given, should ImageJ still continue starting up? Or should it die with an error message? I favor failing fast, which is consistent with other GUI programs. E.g. GIMP:

$ gimp --version
GNU Image Manipulation Program version 2.10.8
$ gimp --version2
Unknown option --version2
$ gimp
... [ the GUI starts up ] ...

Certainly, adding support for --version, which simply prints appService.getApp().getVersion() and then quits, would be straightforward, and we should do it. It would be a new ConsoleArgument plugin, maybe org.scijava.app.console.VersionArgument.

Regarding the UnknownHostException, I’d be fine with moving the stack trace to debug level. I think the errors and/or warnings preceding the trace are sufficient for the standard case. I am curious why @frauzufall and @aklemm got different messages from each other, though.

I also wonder why we see [ERROR] null. If a null message with non-null exception is passed to the logger, it would be better to see only the exception stack trace and no null in the log.

2 Likes

I had to start the updater from the menu to get my error message, that’s why it’s a different message. The UpToDate check finishes without throwing an error (I see Command finished: Up-to-date check in the Fiji status bar). For @aklemm the update check throws the error, it somehow gets past this line which should exit the check in case there is no network. I cannot immediately spot a possible explanation… The haveNetworkConnection method is a bit cryptic to me though.

1 Like

100% agreed. When we ran the command line, some people were laughing because the Fiji logo popped up (for seconds, because we’re on Windows) instead of just telling the version…

Great, that will make users happy :slightly_smiling_face:

Thanks for your instant reply @frauzufall and @ctrueden :green_heart:

Cheers,
Robert

1 Like

Maybe these links help?

2 Likes

App version plugin issue: https://github.com/scijava/scijava-common/issues/359
PR for the null message: https://github.com/scijava/scijava-common/pull/360

4 Likes

Jepp, I saw these, but from what I read there it sounded like this check might not be sufficient. A quick solution would be to just accept that the network test might not work in all scenarios, better catch this connection error afterwards and also just exit quietly.

EDIT https://github.com/imagej/imagej-updater/pull/81 should do it, but I’ll test a bit more.

2 Likes