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
[ADDED] Websocket support #1309
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM, a few comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
A couple of items to add:
|
Keep in mind that websocket{} can define its own host so possibly not the same that the client. I was thinking that if we want to do advertise for WS clients, it would have to be a new field in the INFO. Unless we force the websocket{} to accept only port and fallback to same host than client, in which case we could have connect_urls actually contain only host and have new fields for client port, ws port, this only when sending to WS clients (otherwise it would break backward compatibility).
Good to know, will look into that. |
Ah ok, then for example right now if you connect to a cluster on the websocket port you would get the |
Yes, to be clear, there is no advertise implemented for Websockets as of now, so the connect_urls is the one that you normally get for (regular) client connections. |
Feels like we should no? Its a ws client, so should only have connect_urls that are applicable to its client type. Or empty to start with. Most likely these will be behind a LB so might not be as critical. |
Yes, but the point is that nodes in the cluster do exchange their client's listen spec, which means that this need to be implemented. As I said, if we allow user to specify a different "host" for the listen, then we have to re-implement the current client host:port gossip between servers, not only from server to WS clients. |
Understand regarding host. |
Thinking with MQTT we may need to support it.. |
3dc227b
to
07af9de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general LGTM..
Websocket support can be enabled with a new websocket configuration block: ``` websocket { # Specify a host and port to listen for websocket connections # listen: "host:port" # It can also be configured with individual parameters, # namely host and port. # host: "hostname" # port: 4443 # This will optionally specify what host:port for websocket # connections to be advertised in the cluster # advertise: "host:port" # TLS configuration is required tls { cert_file: "/path/to/cert.pem" key_file: "/path/to/key.pem" } # If same_origin is true, then the Origin header of the # client request must match the request's Host. # same_origin: true # This list specifies the only accepted values for # the client's request Origin header. The scheme, # host and port must match. By convention, the # absence of port for an http:// scheme will be 80, # and for https:// will be 443. # allowed_origins [ # "http://www.example.com" # "https://www.other-example.com" # ] # This enables support for compressed websocket frames # in the server. For compression to be used, both server # and client have to support it. # compression: true # This is the total time allowed for the server to # read the client request and write the response back # to the client. This include the time needed for the # TLS handshake. # handshake_timeout: "2s" } ``` Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
@vinsguru the feature is present in the master branch, and on nightly JetStream images, which you can get by following instructions here https://github.com/nats-io/jetstream#using-docker. The feature is not yet released. |
We also have nightly server images in |
@aricart @ripienaar |
Literally a sigh of relief, as I have been struggling to make wss work with tcp-relay. |
At the next release that is targeted Q4 of this year, but the feature is already available from the main branch and nightly builds: |
Websocket support can be enabled with a new websocket
configuration block:
Signed-off-by: Ivan Kozlovic ivan@synadia.com