remote emacs client connects, but doesn't create new frame in terminal

1.8k views Asked by At

I configured and started an emacs server in TCP mode:

  1. Added (setq server-host "10.16.184.33") and (setq server-use-tcp t) to .emacs
  2. ran emacs --daemon

On the same host, running emacsclient -t brings up an emacs frame in the current terminal, and running emacsclient -c brings up a new graphical client frame, as expected.

On a different host, running emacsclient -t -f ~/.emacs.d/server/server appears to successfully connect to the remote emacs server, but no frame is created in the terminal:

$ emacsclient -t -f ~/.emacs.d/server/server
emacsclient: connected to remote socket at 10.16.184.33

At this point, emacsclient is running in the foreground, and a Ctrl-c stops it with a SIGTERM.

the value of the server-client variable shows that remote emacs client is connected:

server-clients's value is
(#<process server <10.16.184.33:52710>> #<process server <10.16.177.8:59460>>)

Things that I've checked:

  • versions of Emacs and emacsclient: all 24.3
  • when swapping which machines are the server and the remote client, the same problem occurs, except...
  • emacsclient prints an extra error message

    emacsclient: connected to remote socket at 10.16.177.8
    *ERROR*: Could not open file: /dev/pts/26
    

Any ideas of what else to check or configure?

1

There are 1 answers

2
AudioBubble On BEST ANSWER

There is nothing you could “check or configure”. You simply cannot use emacsclient remotely, because both processes share the frame, which does not work remotely for obvious reasons.

If a client connects to an Emacs server, it does not actually create the frame itself. Rather, it merely tells the server what kind of frame to create, i.e. whether a GUI frame or a terminal frame. The server then creates the frame based on the client's request and parameters.

Specifically, in case of a TTY client (i.e. emacsclient -t) the server attempts to create a frame on the client's TTY. Obviously this won't work if the server runs on a different system. TTYs are local and not remotely accessible.

FYI, the “TCP mode” of the Emacs server was never intended for remote access. It is simply a workaround for systems which do not support local Unix sockets, that is, Windows.

You don't even want to try and make it work, because it's horribly insecure. Being intended as local protocol, Emacs server does neither support traffic encryption nor authentication. By running a remotely accessible Emacs server, you allow any other system to execute arbitrary Emacs Lisp on your machine.

The right way to use Emacs remotely is SSH. Setup an SSH server on the remote system, then connect to the system via SSH and start emacsclient -t in the remote shell.