4

I have a remote nrepl which I started via Screen, that I connect to using lein repl :connect. Can I have a value transfer over to a local repl ? The reason I ask is that:

  1. Using Screen means I get headless exceptions when I want to do graphics operations and
  2. Sometimes I would like to get a local copy of a remote value to play with.
juan.facorro
  • 9,791
  • 2
  • 33
  • 41
Hendekagon
  • 4,565
  • 2
  • 28
  • 43

2 Answers2

1

As far as I know there is no transport protocol to send actual Clojure values over the wire. What you can do is launch a local nREPL server, connect to the remote instance and read/eval the response values locally. This should be pretty straightforward when you are just trying to copy basic data from one side to the other. Check the nREPL documentation on how to connect to a server programmatically.

Directly copying things like the state of a java object is not really possible though. You can work around that by creating a new object based on input data you got from the remote, assuming you have a local copy of the source code. The same goes for rendering graphics, get the state as data from the remote and use it locally to trigger the rendering.

Hope this helps!

Dirk Geurs
  • 2,392
  • 19
  • 24
0

I'm assuming your remote process has an open nrepl port that you are connecting to. If that's the case, the best way to connect to that nrepl port from your local machine is probably an ssh tunnel.

ssh -L :localhost: remote-host

Then you'll be able to make an nrepl connect to that port on localhost and do everything you want.

Norman Richards
  • 1,616
  • 2
  • 11
  • 6
  • but what I'm asking is how to get the results back as Clojure values, not strings. Normally if you connect to a remote nrepl, the results are displayed locally, but they are just string output of the remote computation - what I'd like is a local repl, which can talk to the remote one and receive values from it (results of its computations) to play with locally – Hendekagon Sep 20 '13 at 04:11