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

Multiple matlab-control applications on a single machine share the same RMI Registry #14

Open
GoogleCodeExporter opened this issue Mar 18, 2016 · 4 comments

Comments

@GoogleCodeExporter
Copy link

What version of matlabcontrol are you using?
4.1.0


What version of MATLAB are you using?
2009a (7.8.0.347)


What operating system are you using?
Windows 7 / Centos 6.4

Are you using matlabcontrol from inside MATLAB or outside MATLAB?
outside

What steps will reproduce the problem?
1. Run the following program. Call this R1.
2. Whilst R1 is still running, launch R1 again. Call this R2.
3. Allow R2 to run once.
4. Kill R1.
5. Subsequent attempts to launch matlabcontrol in R2 will fail with an rmi 
ConnectException.

public class MatlabControlExample {

    public static void main(String[] args) {
        final MatlabProxyFactory matlabProxyFactory = new MatlabProxyFactory();

        final String command = "disp('hello world!')";
        Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                System.out.println("Invoking " + command);
                MatlabProxy proxy = null;
                try {
                    proxy = matlabProxyFactory.getProxy();
                    proxy.eval(command);
                } catch (Exception e) {
                    e.printStackTrace(System.out);
                    System.exit(-1);
                } finally {
                    try {
                        if (proxy != null) {
                            proxy.exit();
                        }
                    } catch (MatlabInvocationException e) {
                        e.printStackTrace(System.out);
                        System.exit(-1);
                    }
                }
            }
        }, 0L, 1L, TimeUnit.MINUTES);
    }
}


What did you expect to happen? What happened instead?
I expected R2 to continue running successfully (i.e. that no dependency existed 
between independently running VMs).


If there was a stack trace, please copy it here.
matlabcontrol.MatlabConnectionException: Could not bind proxy receiver to the 
RMI registry
    at matlabcontrol.RemoteMatlabProxyFactory.requestProxy(RemoteMatlabProxyFactory.java:104)
    at matlabcontrol.RemoteMatlabProxyFactory.getProxy(RemoteMatlabProxyFactory.java:144)
    at matlabcontrol.MatlabProxyFactory.getProxy(MatlabProxyFactory.java:81)
    at gsa.playpen.MatlabControlExample$1.run(MatlabControlExample.java:30)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.rmi.ConnectException: Connection refused to host: localhost; 
nested exception is: 
    java.net.ConnectException: Connection refused
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
    at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
    at matlabcontrol.RemoteMatlabProxyFactory.requestProxy(RemoteMatlabProxyFactory.java:99)
    ... 12 more
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at java.net.Socket.connect(Socket.java:478)
    at java.net.Socket.<init>(Socket.java:375)
    at java.net.Socket.<init>(Socket.java:218)
    at javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:212)
    at matlabcontrol.LocalHostRMIHelper$LocalHostRMISocketFactory.createSocket(LocalHostRMIHelper.java:71)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
    ... 17 more


Please provide any additional information below.
This can be avoided by altering the port used when the RMI registry is created, 
so as to ensure the port is unique to the running process.





Original issue reported on code.google.com by rakeshka...@gmail.com on 10 Jun 2013 at 2:19

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Could not bind proxy receiver to the RMI registry 
  -> i get the same problem. solved this by: unbind if error occured und bind new one :) this work fine for me :)

Original comment by Aleksej.Turko@googlemail.com on 15 Jan 2015 at 10:25

@GoogleCodeExporter
Copy link
Author

Hi Aleksej,
I get the same problem by trying to establish a connection for the second time.
What exactly do you mean by unbind? (So which code would you enter?)
Thank you very much for your help,
Robin

Original comment by robin.fa...@googlemail.com on 4 Feb 2015 at 6:21

@GoogleCodeExporter
Copy link
Author

Hey ,
I am getting same error when a matlab function is invoked from java.
Could you please tell me how to unbind and bind again.

Original comment by sonam.fg...@gmail.com on 2 Jul 2015 at 11:38

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

1 participant