connect node app running in windows to redis running in wsl - node.js

i have setup wsl in my windows server machine and started the redis service there.
from the windows command prompt i can use wsl redis-cli and run the redis commands.
but my node application is not able to detect the redis inside wsl. i am using redis in my node project.
is there any third party module i need to add to able to connect, this answer showed to add it in python.

the wsl's redis port was readily available.
const client = redis.createClient(); just kept the createClient() config blank and it connected.

Related

MongoDB: No unix socket support on windows

I use Robo 3T as a UI tool for MongoDB on a Windows 8 machine. Now I've deployed the DB to production on a Ubuntu 14 server in Amazon EC2 cloud. When I try to connect from the Windows machine to the Ubuntu one via Robo 3T, I receive the following error:
Cannot connect to the MongoDB at [http://12.345.678.90]:27017.
Error: No unix socket support on windows
Is that a problem I need to fix on my computer by installing something? or it's an issue of Mongo 3T?
If it's an issue on my Windows, what do I have to install in order to make it work?
If it's a Mongo 3T issue, do you know another UI that does support connecting from Windows to Ubuntu?
Perhaps an EC2 solution?
Or maybe some settings I need to change in Robo 3T?
I've tried changing "http" to "mongodb" to no avail. I've also tried removing the protocol prefix as suggested here but I ended up with the error:
Cannot connect to the MongoDB at 12.345.678.90:27017.
Error: Network is unreachable.
Do you have a bindIP setting in your mongo configuration file? Probably that can cause the error.
Either remove the bindIp configuration or allow your IP to access mongo server.
(restart your service after changes the configuration).

Socket communication

I have the amazon ami server, through this i want to achieve socket communication by using nodejs, redis server.
I follwed the below to install nodejs and redis server, npm
https://www.metachris.com/2015/10/how-to-install-nodejs-5-on-centos-and-ubuntu/
https://gist.github.com/dstroot/2776679
Even i installed socket server and socket express also.
when i was try to know the express version this i got this error please see the attached screenshot
Can anyone please suggest me what i can do to achieve socket communication in amazon ami server.
Use node package manager commands. npm -v packagename

How to remote debug a node.js app on heroku?

I'm currently building a node.js chatbot which I then deploy on heroku.
The app uses webhooks which must be at a public URL that the servers can reach. Therefore, running the server locally on my machine will not work. Is there a way I can remote debug my app? Any tips?
I would consider using a tool to connect public URLs to an instance of your app running locally.
Option 1: ngrok
An easy one would be ngrok
Option 2: ssh reverse tunneling
If you have access to any Internet-facing server with ssh and admin rights to enable the GatewayPorts yes sshd configuration, you can do it with ssh remote tunneling. For example:
ssh -n -R 8080:localhost:3000 myserver.example.com
Will allow webhooks sent to http://myserver.example.com:8080 to tunnel to your local app listening on port 3000.
More details on ssh tunneling can be found here
You can indeed debug webhooks on your local computer using a free proxy service like ngrok.
If you want to debug it on Heroku, you can view your real-time logs using heroku logs --tail or use an addon service that stores logs.
Found an easier solution.
Install the LogDNA add-on, and then run the app and see the error stack trace.
then when you see the error and which line it happened on, it is pretty easy to find the problem.
Use Papertrail addon or can also use the logging options mentioned here https://devcenter.heroku.com/articles/logging.

Difficulties connecting to socket.io server with Ionic

An overview of my setup:
A socket.io/node server is being hosted/ran on a computer in my local network.
An Ionic app is attempting to connect to the socket.io/node server to send/receive messages.
If I run the app in the browser with 'ionic serve', I am able to connect to the socket.io/node server successfully.
If I run the app in the emulator or on my device, I am only able to connect to the socket.io/node server if I add the -l (livereload) flag (ionic run android -l).
Originally, I hosted the node server on a heroku instance. I had no troubles connecting with this setup from browser, phone, or emulator. I had to switch to running the node server on a local computer so I have access to a local database.
Any ideas what is going on?
I fixed it by adding 'http://' to the beginning of the connection string.
Not sure why Ionic's livereload enabled me to connect without the 'http'

How should my local server communicate with an EC2 server?

I have a node.js server running on ec2. I'd like for that server to automatically push data to another node.js server that is running on my laptop.
What is the best way to do something like this?
You could use a service like showoff.io to create an entry point to access your local laptop, or you could just create an SSH tunnel by running this command on your laptop:
ssh -R port:localhost:remoteport ec2-host
That will allow port on the loopback interface of your EC2 server to connect to remoteport on your laptop.
Then just modify your code to connect to the node.js program running on your laptop via the IP of 127.0.0.1 and port of port.
You could have the EC2 node.js call a function from the local node.js, and pass the data as variables

Resources