nREPL session IDs

38 views
Skip to first unread message

Jony Hudson

unread,
Jan 29, 2014, 7:21:01 AM1/29/14
to clojur...@googlegroups.com
Hi,

 I'm trying to implement an nREPL client (browser based, in javascript) using the drawbridge transport. On the whole it's working well, but I'm having a problem with session IDs that's got me stumped. I think maybe the problem is that I don't understand really what the session IDs are for, but the apparent problem is as follows ...


I POST a request to the drawbridge endpoint to evaluate some code. I don't have a session ID test (this is the first communication I send to the server), so I don't include a session key in my message. Message JSON payload:

{"op":"eval","code":"(+ 1 1)","id":"1097c65d-2aaa-456c-8739-8f4fc68e7be6"}

I poll the REPL endpoint and I get some sensible looking replies back:

{"ns":"user","value":"2","session":"0280dd9d-5cf5-47f5-a1ed-4709383d5a01","id":"1097c65d-2aaa-456c-8739-8f4fc68e7be6"}
{"status":["done"],"session":"0280dd9d-5cf5-47f5-a1ed-4709383d5a01","id":"1097c65d-2aaa-456c-8739-8f4fc68e7be6"}

From these I take the session parameter and store it to use with my subsequent requests. If I try and issue another evaluation request, using the session ID that I captured:

{"op":"eval","code":"(+ 4 5)","id":"39976a0f-f88f-46fa-90da-75318262fc1b","session":"0280dd9d-5cf5-47f5-a1ed-4709383d5a01"}

Then I get an error back:

{"status":["unknown-session","error"],"session":"0280dd9d-5cf5-47f5-a1ed-4709383d5a01","id":"39976a0f-f88f-46fa-90da-75318262fc1b"}


Anybody able to point me in the right direction here?

Many thanks in advance,


Jony

Jony Hudson

unread,
Jan 31, 2014, 9:39:12 PM1/31/14
to clojur...@googlegroups.com
Think I might have figured out the answer to this one, by peeking at the traffic from the nREPL client. I think I must have not read the docstring for the 'session' function! :


"If no :session ID is found, a new session is created (which will only persist for the duration of the handling of the given message)."

Whereas a session obtained with the :clone op and no given session to clone seems to persist across messages.

Hopefully someone will shout up if I've got this wrong :-)


Jony

Chas Emerick

unread,
Feb 1, 2014, 7:47:36 AM2/1/14
to clojur...@googlegroups.com
Correct, :clone-ing a session will ensure it sticks around.

- Chas
> --
> You received this message because you are subscribed to the Google
> Groups "clojure-tools" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure-tool...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages