Question

I'm using MATLAB (2013a) on a linux machine remotely. I'm forwarding X11 via ssh using ssh -X (OpenSSH_5.9p1, OpenSSL 0.9.8y 5 Feb 2013). The X11 server is XQuartz 2.7.4 (xorg-server 1.13.0) on a Mac OS 10.8.5.

When my MATLAB crashes, it somehow kills the X11 connection, and I need to reconnect via ssh to re-estabilish a fresh X11, otherwise MATLAB refuses to start. Is it normal for an X11 application to do things like this? Is there a way to fix the X11 without reconnecting via ssh?

This happens when I don't have splash (-nosplash), no gui, no editor, no plots as well.

EDIT: I am running MATLAB over a shell (bash) inside tmux (or sometimes screen).

Was it helpful?

Solution

You need to have the DISPLAY variable set properly for X11 forwarding to work correctly -- something ssh -X or ssh -Y should do for you. What is the value of DISPLAY before and after the crash (echo $DISPLAY)? It should be something like localhost:10.0. I'm wondering if the variable gets messed up does not exit cleanly.

Also, try using -Y instead of -X to see if that makes any difference. If that doesn't help, try adding ForwardX11Trusted yes in /etc/ssh/ssh_config.

OTHER TIPS

It would be helpful to show the complete sequence of commands you use to initiate the connection and start MATLAB, along with any error messages. For example:

# batch mode
client$ ssh -v -x user@server           # small "x" disables X11 forwarding
server$ unset DISPLAY
server$ nohup matlab -nodesktop -nodisplay -noFigureWindows -nosplash \
          -r "ver; quit;" > m_output.out 2>&1 < /dev/null &

# interactive mode
client$ export DISPLAY=localhost:0.0
client$ ssh -v -X user@server           # enable X11 forwarding
server$ matlab

A few ideas:

  • turn on more verbose output (ssh -vv), and investigate the reason the SSH connection was closed (debug output messages or any log files)

  • are you directly running a command from ssh, or is this done in two steps (connect using ssh, then interactively start command from allocated shell)?

  • If I understood correctly, this also happens when not using X11 forwarding?

  • does this happen when using nohup or screen/tmux as well? See this

  • try adding TCPKeepAlive to your ssh config

  • how about using auto-reconnect SSH connections

  • are you using any custom SSH configurations? (if so show the relevant parts from ssh_config and sshd_config files)

  • try running another process in the background before starting MATLAB

It's been reported before that MATLAB can sometimes mess up the bash shell when it returns. MathWorks recommended using a different shell instead (like tcsh or zsh).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top