-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support WebSocket Connectivity #315
Comments
Always open to PRs, have you looked at the NGINX plugin though? That may fit the bill. |
According the last tests we did, nginx can only forward and keep a websocket connection open, and it still needs a server to operate the full websocket handshake… Alright then, we'll see what we can do ! |
Thanks for the information. We have a strategy session this week on NATS, so will discuss for sure. |
Alright, so we have integrated our gateway code into nats. So basically for each ws connection we have incoming, we pop a tcp connection to nats. It's close to what we had before, but this time we wrote it into nats. It's far from being an ideal solution (it's more of a proof of concept) but it's working, and at least it allows us to scale up if needed. Did you get any outcome at the session by the way ? |
You can multiplex the ws connections through one or a small group on NATS TCP connections. We did discuss and it will be added to the roadmap. Timing is unclear since we have higher priority items that are above this. |
github.com/Terry-Mao/goim Supports multiple protocols (WebSocket,TCP,HTTP) |
A rough sketch on my take on this (without changing NATS):
Why STOMP?
|
Some good thoughts, we are still looking at providing the Node.js like API over websockets. |
Also there is this: https://github.com/sohlich/nats-proxy |
@derekcollison
The Dart implementation of websockets is 100% independent of web browser btw. SO it does work everywhere. I plan to use golang and dart in the my microservices sitting behind NATS. |
I'm a little confused by this issue. Is it specifically to support web socket connections into NATS, ie not the behavior of some web socket libraries which degrade to long polling when web sockets are not available? In the interim, spin-up a node server using socket.io and the node client (and TypeScript, not Dart), imo. |
@sfrooster Michael, I believe OP was just wondering what our plans are in general. We have had some internal discussions about supporting NATS over a WebSocket transport in past, but have not taken it much beyond conversation. I'd say we're open to discussion/proposals. |
+1 Long polling is very expensive specially on mobile devices, combined with the new proposed client auth we'd be able to allow clients (mobile, browser etc) to auth and connect directly to the cluster without having to go through a proxy that manages subscriptions. |
One one more point, adding websocket support to the node.js client is pretty straightforward https://github.com/nats-io/node-nats/blob/master/lib/nats.js#L556 - here we could perform a simple check on the connection url based on which decide whether to establish a tcp connection or a ws connection. Everything else should work out of the box. |
now i use https://github.com/joshglendenning/websocket-nats and https://github.com/joshglendenning/ws-tcp-relay in browser,it works, but if would be more good for nats server to support it natively. |
Not a native support but a more natural one than nats-proxy and ws-tcp-relay: https://github.com/orus-io/nats-websocket-gw |
Some additional comments from users in another issue: @isobit commented on May 14 @cdevienne commented on May 17 |
@derekcollison Still no plans to add native support for websockets? I would assume people would ask for it even for NATS Cloud (including myself) |
We are considering it.. |
Well, you have a customer right here, with a live consumer app. Happy to show you and explain my use case. |
If you're willing to spare few minutes with me that is
;) |
need native support +1 |
Any update on websocket support? PaaS providers don't support tcp servers but they do support websockets. So I'm using the websocket transport as a way around this. (+Bonus points for browsers being able to connect) I'm not going to wait around until nats supports websockets, so in the meantime I'll have to fork it to add the support myself. |
Still on our list but other items ahead of it, so feel free to implement a solution that works for you. |
Implementing websockets ended up being easier than I thought. The client library .../nats-io/go-nats didn't require any changes, since it supports supplying a custom dialer. And for the server library .../nats-io/gnatsd I was able to get working with minimal changes by creating a small wrapper library around .../gorilla/websocket to make the websocket.Conn satisfy io.Reader and io.Writer and used it in place of net.Conn. It's mostly a temporary solution until websockets are implemented officially, but it works and serves as a proof of concept and allows me to test what I'm working on. I now have it properly running on heroku using websockets. |
@noxyal nice! I am curious: does the websocket-enabled go-nats works with https://github.com/orus-io/nats-websocket-gw as a server ? |
@cdevienne You can check the custom dialer I used here: Then In my code I set it as the custom dialer like this: natsOptDialer := nats.SetCustomDialer(&WSwrapper.Dialer{}) |
the blog(https://nats.io/blog/2018-year-review-upcoming-2019/) shows native websocket support will land in 2019, does it has a timeline yet? |
1H 2019 |
Would this apply to nats-streaming as well? |
Yes since a connection to STAN is logical.. |
in case someone is still looking nats client or nats-streaming client via websockets https://github.com/blinkinglight/go-nats.io-websocket |
Thanks will have @aricart take a look. /cc @ColinSullivan1 |
Would this WebSocket work include "TLS-only" mode for server and clients, removing the initial plaintext INFO message ? This is regarding discussion in #291 |
Most likely we would make the WS connections be able to traverse through proxies and LBs etc that supported TLS. Meaning yes would be a TLS-only, however there is no plan to remove that for normal connections. |
I created #1044 as a point to discuss such option and if it makes sense work on PR to enable it |
I saw, websockets will support this mode, but there are no plans to change the way connections work today with sending INFO first unencrypted before switching to TLS. |
Will the websocket connectivity be supported so that this can replace rabbitmq? |
Yes, we have plans to support websockets post JetStream launch. |
This is supported now on master. |
Hi,
At @gretaio, we need our signaling server to talk with web browsers, and in order to perform this, we setup a small proxy to gateway websocket to tcp so it can talk to nats.
I saw on the todolist that you plan on adding a websocket strategy, and that's something we would greatly appreciate as that'd basically half the number of connections we need to have open 👍.
So, would you be open to a PR regarding this?
The text was updated successfully, but these errors were encountered: