sente - client ids and ring plumbing

165 views
Skip to first unread message

Colin Yates

unread,
Mar 26, 2015, 11:22:45 AM3/26/15
to clojur...@googlegroups.com
I have read the documentation but I think I am having a bad day as I just can't get it to click.

Essentially I would like each new 'client' to be uniquely identified where:
- a new client is created for every 'client-less' request (e.g. a new tab) - each subsequent request is then associated with that client
- server restarts can happily drop all existing clients and they can become new clients
- authentication is handled elsewhere

I can't use the ring's session-id as it is shared by every tab. I notice a 'client-id' which appears to be unique across tabs but the FAQ implies that 'client' is the wrong granularity.

I am sure I am being a numpty, but what do I need to do. Is a user-id-fn of :client-id sufficient?

Daniel Kersten

unread,
Mar 26, 2015, 12:19:11 PM3/26/15
to clojur...@googlegroups.com
I actually would like to do the same thing. For authentication, I would use a JSON Web Token and would happily pass that with my requests manually. I don't care if client id's change because my server is stateless-REST-like.



--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescript+unsubscribe@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Wei Hsu

unread,
Mar 26, 2015, 8:54:46 PM3/26/15
to clojur...@googlegroups.com
If you want each client to be unique, what if your user-id-fn could just generated a UUID?

On Thursday, March 26, 2015 at 9:19:11 AM UTC-7, Daniel Kersten wrote:
> I actually would like to do the same thing. For authentication, I would use a JSON Web Token and would happily pass that with my requests manually. I don't care if client id's change because my server is stateless-REST-like.
>
>
>
>
>
>
> On Thu, 26 Mar 2015 at 15:22 Colin Yates <colin...@gmail.com> wrote:
> I have read the documentation but I think I am having a bad day as I just can't get it to click.
>
>
>
> Essentially I would like each new 'client' to be uniquely identified where:
>
>  - a new client is created for every 'client-less' request (e.g. a new tab) - each subsequent request is then associated with that client
>
>  - server restarts can happily drop all existing clients and they can become new clients
>
>  - authentication is handled elsewhere
>
>
>
> I can't use the ring's session-id as it is shared by every tab. I notice a 'client-id' which appears to be unique across tabs but the FAQ implies that 'client' is the wrong granularity.
>
>
>
> I am sure I am being a numpty, but what do I need to do. Is a user-id-fn of :client-id sufficient?
>
>
>
> --
>
> Note that posts from new members are moderated - please be patient with your first post.
>
> ---
>
> You received this message because you are subscribed to the Google Groups "ClojureScript" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.

Colin Yates

unread,
Mar 27, 2015, 4:52:44 AM3/27/15
to clojur...@googlegroups.com
I did try that but then I can't find where to access that in the messages received from a client. I know I am going to kick myself...

Dillon Forrest

unread,
Mar 27, 2015, 1:07:06 PM3/27/15
to clojur...@googlegroups.com
Hey Colin, as a crazy coincidence, I'm trying to accomplish something very similar. I started wondering if I should set a session uuid server-side, but I'm sure there's a more elegant solution out of the box. Also expecting to kick myself once I know the correct way to do it. :)

Daniel Kersten

unread,
Mar 27, 2015, 1:43:10 PM3/27/15
to clojur...@googlegroups.com
We should start a club for people who will be kicking themselves :)

To unsubscribe from this group and stop receiving emails from it, send an email to clojurescript+unsubscribe@googlegroups.com.

Dillon Forrest

unread,
Mar 27, 2015, 1:45:51 PM3/27/15
to clojur...@googlegroups.com
hahaha i'm all about that :)


--
i blog about starting a company here
i also host a podcast

You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/AZlkAACi7gc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.

Dillon Forrest

unread,
Mar 28, 2015, 6:58:50 PM3/28/15
to clojur...@googlegroups.com
Hi Colin, just curious, but have you been able to figure out your Sente issue?

Upon second reading, I realize my issue is different and much less complex than yours. I just want to uniquely identify 1 tab in 1 browser on 1 device, but have that id persist across user refreshes or clicking links or anything which will prompt a second initial socket handshake within the same tab. I still can't figure it out though. D: Does anybody have any ideas?

(logged my own issue here: https://github.com/ptaoussanis/sente/issues/118)

Sente creator Peter Taoussanis has been very awesome and patient though. He suggested logging a github issue with questions!

Dillon Forrest

unread,
Mar 28, 2015, 9:45:48 PM3/28/15
to clojur...@googlegroups.com
I logged an issue with ring, and they told me that web servers can't enable knowing about the same tab refreshing because browsers don't expose tab identities.

I resolved to just use (session|local)Storage. I think that's the only way to isolate identity down to the tab level but also persist identity across refreshes and pageloads. Thanks Dan for commenting on mah sente issue! :)

Sven Richter

unread,
Mar 29, 2015, 3:04:22 AM3/29/15
to clojur...@googlegroups.com
Hi Colin,

I had the same need for this almost a year ago. And it turned into this issue: https://github.com/ptaoussanis/sente/issues/65
Peter was very helpful explaining things and so I went with the client side generated uuid which I stored in the localstorage, IIRC.

However, I just looked at it and a new issue came up with a similar need:
https://github.com/ptaoussanis/sente/issues/82
And it seems Peter did some unreleased work on it.

Just have a look there and see if it helps you somehow.

Best Regards,
Sven

Colin Yates

unread,
Mar 29, 2015, 4:30:13 AM3/29/15
to clojur...@googlegroups.com
Hi both, no - I still haven't resolved this, but using the client-id
is "good enough" for now. I will revisit this when I have some more
time, but those links from Sven looked interesting.

+1 for Peter's helpfulness.
Reply all
Reply to author
Forward
0 new messages