-
-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server, user and client - current socket communication scheme problem #82
Comments
Hi valichek, apologies for the delay getting back to you! This is something I'm going to need some time to think deeply about. Really pinned with work atm though, so unfortunately no way I'm going to have that time over the next few weeks. Will keep this issue open and come back to you once I've had the necessary time to think about it? Sorry I couldn't be more helpful right away! |
@ptaoussanis, I'm actually hitting this right now as well. I've built a really nice server/client side navigation scheme on top of Sente that I'm hoping to open source in the next few weeks. Each browser tab maintains a websocket that it uses to send navigation events to the server - the server responds with updated page state information for each route. I'm using the client's session ID as my I see that you supply a |
Hey Sam, taking a look into this now. |
Okay! Took the opportunity while I was in the code to clean up some things I'd been meaning to. Have an experimental + untested release up on Clojars: Relevant changes:
So present situation:
The latter of course means that it's possible to do something like set a user id as the combination of a server-side login uid and client-side uuid (per tab, etc.). I also made the client-uuid configurable, so you can actually decide whether you want the uuid to be, say, chsk local (the default), or tab local over multiple chsk connections. Feedback and/or bug reports on this release would be welcome! Cheers :-) |
It looks really great! I would like to suggest another feature. Maybe generating client-uuids at the server side is better idea. It could be added as option. |
Hi Valichek, The trouble there is that there's no reliable way of actually generating a server-side uuid for clients reliably. If you generated (say) a random uuid for each connection, then you'd lose client identity on reconnects. If you generated (say) a random uuid for the first connection, then gave it to the client to relay - you'd still be subject to the client potentially lying about the id it's been given. An alternative would be for the server to somehow try hash the client's handshake request and try to identify the client that way (e.g. via IP address, etc.) - but that can be inaccurate, and would still depends on the client's honesty to not be forging headers, etc. The current approach instead proposes that we treat all client uuids as forgeable, and derives security in two ways:
Does that make sense? |
Hmm, so I tried this out, making sure to clean and rebuild my clojure and clojurescript, and I'm now seeing this error server side: WARN [taoensso.sente] - Client's Ring request doesn't have a client uuid. Does your server have the necessary keyword Ring middleware?: and my websocket isn't connecting. I do have the proper middleware, but I see that the params field is empty. I'll see what I can do - @ptaoussanis, I know you said this is untested, but have you gotten a basic socket connection working? Will dig a little post dinner. Thanks for this, by the way! Once I get this working this'll be huge. |
Hold that, I may have done a poor job cleaning clojurescript. I just looked in the cljsbuild folder and I still see old sente. Trying again. |
Yeah, user error. Works great! |
No problem, happy to hear you have it working. Let me know how well this does/n't end up fitting your use case? Good luck with the project! Cheers :-) |
I'm now about to pass (let [reply (or ?reply-fn #(send-fn client-uuid %))]
(reply resp)) Looks perfect to me. |
Hi, Peter |
If you're worried about poor client uuid implementations:
Any alternative will need to address the points I raised before. So the client [uu]id is currently being used only for the one thing the server cannot reliably do, which is provide some form of id that persists across disconnections and that's stable from first connection. What the server chooses to do with that id is up to the server. |
I agree with you. That make sense. Thank you |
No problem. And just to clarify - I'm not suggesting that the current approach is the only, or best one. Just suggesting that any alternatives would need to address our particular needs+limits. I haven't been able to give the client id stuff much thought yet, so it's very possible that there's a better idea to be had. Your thoughts have been (+ would continue to be) very helpful. Cheers! |
Hmm. As I mentioned in the other issue I posted, in the latest snapshots my clients aren't receiving messages sent via UUID. Has some change come in since the first |
Nothing intentional that I recall. My first guess would be that your build or build environment have somehow gone bad. Since these may be related, let's keep the discussion at issue #105 for now. Going to follow up with some questions at #105 now. |
Closing for now as it's likely I won't be able to assist with this in at least the short/medium term. Might be something to investigate again some time in future if someone can provide a clear + updated summary of specific motivations + can address how the current user-id based recommendations are inadequate. Appreciate all the input given so far! Cheers :-) |
Hi, I would like proceed with #65 discussion.
Server cannot push message to specific client connected by websocket, only to user.
Filtering messages on client side is not good, because it uses necessary server resources to send all messages to all user clients and for high loaded apps it is critical.
I don't understand why the current scheme when server sends messages by uid is preferable. Maybe for common use apps it is OK, but in general case it is highly objectionable.
I've investigated the code and don't see big problem to give server a little more control on clients.
So here is the changes I propose.
0) generate uuids by server (to guarantee uuids uniqueness), so move from client-uuid to uuid to distinct it
current
{<uid> <#{hk-chs}>}
proposed
{<uid> {<uuid> <hk-chs>}}
,fn [user-id uuid ev & [{:as opts :keys [flush?]}]]
and set uuid to nil by default to leave active current scheme:chsk/uuidport-close
and:chsk/uuidport-open
It is just common solution and it won't break current communication scheme while adding possibility to build more flexible apps.
The text was updated successfully, but these errors were encountered: