node-spdy | SPDY server on Node.js | Runtime Evironment library
kandi X-RAY | node-spdy Summary
kandi X-RAY | node-spdy Summary
SPDY server on Node.js
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of node-spdy
node-spdy Key Features
node-spdy Examples and Code Snippets
Community Discussions
Trending Discussions on node-spdy
QUESTION
I am creating an application(Nuxtjs
) and am having troubles determining a good approach for sending data to the API(expressjs
) and retrieving real-time updates. It seems that i can create "bi-di" connections with both protocals [Server Sent Events(SSE
) and Axios
or Websocket(WS
)].
Both technologies work with most of the browsers, so i do not see a need to add additional libraries such as socket.io
- For those individuals that do not have a current browser (too bad).
The application is based on user input of form data/clicks. Other users are then notified/updated with the information. At which point, the user can respond and the chain goes on(Basic chat like flow some information will be exchanged quickly while some may not or ever).
In my experience, the user flow would rely more heavily on listening for changes than actually changing the data - hence why i'm considering SSE
. Unfortunately, both protocols have their flaws.
Websockets:
- Not all components will require a
WS
to get/post information as such it doesn't make sense to upgrade a basic http connection at the additional server expense. Therefore another method other thanWS
will be required(Axios/SSR
).Example: Checking to see if a user name exists
- Security firewalls may prevent
WS
for operating properly express-ws
makes sockets easy on the API end- I believe you can have more than 6 concurrent connections by one user (which may be pro and con)
Server Sent Events
- Seems like the technology is fading in favor of
WS
- Listening to the events seem to be as easy as listening to events for
WS
- No need to upgrade the connection but will have to use
node-spdy
within theexpressjs
API - This may also be a good implementation forWS
due to multiplexing - Little more backend code to setup
http2
and emit theSSE
s(Ugly code as well - so functions will be made) - Limited to HTTP limitations (6 concurrent connections) which is a problem as the users could easily max this out(ie. having multiple chat windows open)
TLDR
The application will be more "feed" orientated with occasional posting(which can be handled by Axios
). However, users will be listening to multiple "feeds" and the HTTP limitations will be a problem. I do not know what the solution would be because SSE
seem like the better option as i do not need to continually handshake. If this handshake is truly inconsequential(which from everything i have read isn't the case) than WS
is likely a better alternative. Unfortunately, there is soooo much conflicting information regarding the two.
Thoughts?
...ANSWER
Answered 2019-Nov-07 at 01:10I personally avoid using websockets
as a 2-way communication between client
and server
.
I try to use sockets to broadcast data from server to users or a single user(socket)
, so they can get real-time updates, but for the post requests from client to server I tend to use axios or something similar, because I don't want to pass sensitive data (like access keys etc) from client
to server
.
My data flow goes something like
- User posts data to the server using
axios
,SSE
or whatever - Backend server does what it has to and notifies socket that an event has occured
- Socket server then notifies who he has to
My problem with using sockets to send data from client to server is the authentication issue. Technically, you can't pass anything that is not available to client-side javascript through a socket, meaning that to authenticate the action you will have to send sensitive information through a websocket. This is an issue for multiple reasons - if your sensitive data can be accessed using client-side js, there is a bunch of attacks that can be done here. Also someone can listen to the communication between ws and client. This is why I use API calls (axios etc) and store sensitive data to http-only cookies.
So once server wants to notify the user that something has happened, you can easily do that by telling the websocket server to send the data to the user.
You also want to keep your API server stateless, meaning no sockets in your API. I use separate server just for websocket connections, and my API server and websocket server communicate using redis. Pub/sub is a really neat feature for internal server communication and state management.
And to answer your question regarding multiple connections - you can use a single connection between your websocket server and client, and broadcast data using channels. So one channel would be for notification feed, other channel could be for story feed etc.
I hope this makes sense to you. This stack has worked really good for me.
QUESTION
Scenario:
I have an express.js server which serves variations of the same static landing page based on where req.headers.host
says the user is coming from - think sort of like A/B testing.
GET tulip.flower.com
serves pages/flower.com/tulip.html
GET rose.flower.com
serves pages/flower.com/rose.html
At the same time, this one IP is also responsible for:
GET potato.vegetable.com
serving pages/vegetable.com/potato.html
It's important that these pages are served FAST, so they are precompiled and optimized in all sorts of ways.
The server now needs to:
- Provide separate certificates for
*.vegetables.com
,*.fruits.com
,*.rocks.net
- Optionally provide no certificate for
*.flowers.com
- Offer HTTP2
The problem is that HTTP2 mandates a certificate, and there's now multiple certificates in play.
It appears that it's possible to use multiple certificates on one Node.js (and presumably by extension Express.js) server, but is it possible to combine it with a module like spdy, and if so, how?
Instead of hacking node, would it be smarter to pawn the task of sorting out http2 and SSL to nginx? Should the caching network like Imperva or Akamai handle this?
...ANSWER
Answered 2017-Mar-01 at 14:34Nginx can handle SSL termination nicely, and this will offload ssl processing power from your application servers.
If you have a secure private network between your nginx and application servers I recommend offloading ssl via nginx reverse proxy. In this practice nginx will listen on ssl, (certificates will be managed on nginx servers) then it will reverse proxy requests to application server on non ssl (so application servers dont require to have certificates on them, no ssl config and no ssl process burden).
If you don't have a secure private network between your nginx and application servers you can still use nginx as reverse proxy via configuring upstreams as ssl, but you will lose offloading benefits.
CDNs can do this too. They are basically reverse proxy + caching so I dont see a problem there.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install node-spdy
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page