How to develop/refactor a node.js project that uses socket.io and send JSON data from a client to another in a room?
I've developed a project with node js and socket.io that there is a board game in a part of it, the user1 select a place and its information send to the user2 in JSON format and this part developed with socket.io.
now I want to deploy the project to AWS Lambda but I realize that socket.io can't run because of serverless nature, so my question is how can I develop this board game with AWS Lambda and what technology/library can I use?
You cannot do socket.io like bi-directional communication only using AWS Lambda since it is stateless and asynchronous. You can use AWS IOT Web Sockets for this(Optionally with Lambda).
Related
I'm working on creating mock sever for my Angular application. On frontend I have library for STOMP. And regularly my frontend communicates with Api written in Java.
But additionally I start mock nodejs api which returns hard coded Json files when remote server is down.
Now I'm trying to write mock nodejs websockets server which will community with Angular client when remote server is down. But I would like to keep it simple
I found StompJs library but seems like it needs STOMP message broker (like Rabbit?). It's seems to me a bit complicated for mock server. Is there any option to skip this broker step and keep it as simple as possible?
I'm building a custom serverless chat on AWS.
I want to use WebSockets for updating the messages.
I found that Socket.io is amazing for what I need and it also supports heartbeat as fallback if WebSockets does not work.
My problem with Socket.io is that is does not have server for AWS ApiGateway.
Is there any library that will replace Socket.io for me on serverless?
I'm new to GraphQL, Apollo, AWS S3, and Redux. I've read the tutorials for each and I'm familiar with React Native, Node, Heroku, and Mongo. I'm having trouble understanding the following:
how a "GraphQL Server" is hosted for a mobile device using React Native?
can I create the GraphQL server with Node and host it on AWS S3?
how to grab that data by using Apollo/GraphQL in my React Native code and store that data locally using Apollo/Redux?
do I have to use Graphcool as the endpoint from the start instead? All I'm trying to do is pulling data from my database when the app loads (not looking to stream it, so that I am able to use the data offline).
Where should I look to get a better understanding?
I have a couple comments for you in your exploration of new territory.
GraphQL is simply the query language the talks to your database. So you are free to run any type of api (on a server, serverless, etc.) that will use graphql to take in a graphql query/mutation and interact with your database.
GraphCool is a "production-ready backend" basically back-end as a service. So you wouldn't worry about running a server (as I believe they run most everything on serverless infrastructure) or managing where your DB is housed.
You can run an HTTP server on AWS EC2 or serverless using AWS Lambda. (Or the same flavor with Google or Azure). Whatever you decide to use to accept requests, your endpoint will accept graphql query strings and then do stuff with the db. AWS S3 is more of static storage. You can store files there to be retrieved, or scripts that can be pulled, but S3 probably isn't where you would want any server-like code to run.
Apollo would be a tool to use on your frontend for easily interacting with your graphql server. React-Apollo
Apollo/Redux may help you then manage the state throughout the app. You'll simply be loading the data into the app state on load then interacting with that state without needing to make any more external calls it sounds like.
Hopefully this was helpful.
I'm using node js with aws lambda functions for my web application. I want to use web socket in my web app. And socket.io is a very famous library for node.js.
But I'm not sure how can I use it in aws lambda. can anyone let me know how to do it, is it possible using lambda functions?
Can't use socket.io with lambdas. Lambdas have a limit on time it can be executed, so holding open connection with a client is impossible.
What you can do though is use SNS. Lambdas can publish messages to SNS topics and lambdas can be invoked with SNS.
Workaround exists for this - it's the WebSockets over MQTT in AWS IoT. This way you can execute your Lambda functions from open socket connections.
Currently, AWS API Gateway supports WebSockets.
Unfortunately, I didn't manage to connect via socket.io since it generates a custom URL with additional params: /?EIO=3&transport=polling&sid=< id>
But I've found tiny WebSocket wrapper sockette (used this tutorial), and it works fine!
Here is my set up:
Node.js server with RedisCloud, and client mobile app written in Unity C#.
I'm trying to push message from Node.js server to UnityC#.
At first, I try to get Unity access RedisDB directly but that is too dangerous having Client connecting to DB, and open the port.
So, what module works well between Node.js & Unity for message pub/sub? or 3rd party services that takes data from Redis, and push to Client?
I think socket.io will work but it seems just too much work for Client to write code handling that.
Is there something like Firebase or Photon, but instead using Firebase DB, point to my own RedisDB?
Thanks.
If your mobile client is for iOS then you should use "Apple Push Notifications", if Android, you should use "Google Cloud Messaging".
You can easily find modules for these tasks on npm, for example: https://www.npmjs.com/package/gcm
Use a Cloud service like Pusher or Realtime (the company I work for). Simply subscribe a channel on your mobile app using the Realtime Unity SDK and publish the messages from your server using the Node.js SDK. You don't need to worry about the dirty backend details (security, scalability,...)
More at http://framework.realtime.co/messaging