Skip to content
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

Differentiating license issues with connection issues #22

Open
krisan6 opened this issue May 2, 2019 · 4 comments
Open

Differentiating license issues with connection issues #22

krisan6 opened this issue May 2, 2019 · 4 comments

Comments

@krisan6
Copy link

krisan6 commented May 2, 2019

We're running matconsolectl in a server job and using a corporate license pool.
Sporadically, we're getting this exception:

Exception in thread "main" matlabcontrol.MatlabConnectionException: MATLAB proxy could not be created in 180000 milliseconds
at matlabcontrol.RemoteMatlabProxyFactory.getProxy(RemoteMatlabProxyFactory.java:176)

I suspect that this is caused by being out of matlab licenses, but as far as I can tell from the matconsolectl source code, it does not have any special handling of license issues compared to e.g. network issues. Or am I misdiagnosing this and license errors will not get MatlabConnectionException timeouts?

It would be really nice if one could get the error message we get when running matlab directly, i.e.

"License checkout failed.
License Manager Error -4
Maximum number of users for MATLAB reached.
Try again later."

I'm not sure where to start looking for the above output though, so not sure how to fix it (if this really is the issue that I think it is)

@nedtwigg
Copy link
Member

nedtwigg commented May 2, 2019

It is probably possible to accomplish this, but it may be difficult. Happy to accept a PR for this, but we have no plans to implement. The only advice I have is to follow the stacktraces.

@krisan6
Copy link
Author

krisan6 commented May 3, 2019

My guess (haven't figured out how to test this yet...) is that it is this code in RemoteMatlabProxy that loses the information:

		//Call a remote method, if it throws a RemoteException then it is no longer connected
		try {
			_jmiWrapper.checkConnection();
			connected = true;
		} catch (RemoteException e) {
			connected = false;
		}
		_isConnected = connected;

Where _isConnected is also the return value from the method. Without changing the method signature, I guess one could store the "RemoteException e" in a field and have RemoteMatlabProxy add something to this code:

		if (callback.getProxy() == null) {
			throw new MatlabConnectionException("MATLAB proxy could not be created in " +
					_options.getProxyTimeout() + " milliseconds");
		}

So that it will access the stored exception (e.g. from the "callback") thing and appends it to the new exception message.
I could hack up something like that, but I'd like to be able to test it and see that the RemoteExceptioncontains what I hope it does. My knowledge of rmi is somewhere below zero and how to correctly emulate a matlab license server without licenses is also a bit unknown.

Does the above seem reasonable way to try to address this?

@nedtwigg
Copy link
Member

nedtwigg commented May 6, 2019

That seems very reasonable! If it works for you, I'd be happy to merge a PR for it.

@krisan6
Copy link
Author

krisan6 commented May 6, 2019

After playing around a bit with the code, I realize that I'm badly out of my depth here and being unable to find a reasonable way to test this, I'm not sure I'd recommend merging my patch. I'll see if I can roll it out on our jenkins and see if it over time manages to catch the license situation or if this is just a null patch. If I manage that, I'll check back here, but it could take weeks or months until it triggers the problem I'm trying to get at.

Anyway, attaching it in case anyone can already see that this is completely wrong and wants to have a stab at improving it.

exception-propagation.patch.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants