running shadowsocks-nodejs on heroku - javascript

What I am trying to accomplish: Get shadowsocks-node.js to run on heroku.
shadowsocks-nodejs is a lightweight tunnel proxy which can help you get through firewalls.
I got it to run locally with both processes on the same machine.
My next step was to deploy it to heroku and run server.js there and local.js locally on my machine. However, I can't seem to get a connection going.
My problem: the connections seem to be refused by the server process.
node local.js outputs:
calculating ciphers
server listening at port 1080
server connected
concurrent connections: 1
remote connection refused
server connected
concurrent connections: 1
remote connection refused
server connected
and so on...
server.js outputs (via heroku logs):
012-10-27T20:39:57+00:00 app[web.1]: server connected
2012-10-27T20:39:57+00:00 app[web.1]: concurrent connections: 1
2012-10-27T20:39:57+00:00 app[web.1]: server disconnected
2012-10-27T20:39:57+00:00 app[web.1]: concurrent connections: 0
2012-10-27T20:42:02+00:00 app[web.1]: server connected
2012-10-27T20:42:02+00:00 app[web.1]: concurrent connections: 1
2012-10-27T20:42:02+00:00 app[web.1]: server disconnected
and so on.
Chrome gives back the error:
Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.
(makes sense)
This is my config.json that is used by shadowsocks:
{
"server":["https://damp-woodland-7539.herokuapp.com"],
"server_port":58954,
"local_port":1080,
"password":"barfoo!",
"timeout":60
}
I edited server.js to read (line 31):
//PORT = config.server_port;
PORT = process.env.PORT || 5000;
as advised for heroku apps.
And this is my package.json file:
{
"name": "shadowsocks-nodejs",
"scripts": {
"start": "server.js"
},
"version": "0.0.1",
"engines": {
"node": "0.8.x"
},
"dependencies": {
"fs": "*",
"net": "*"
}
}
This might be just a simple setup issue or some incorrect addresses. Would be great if someone of you could help me out.
Thanks a lot!

shadowsocks-nodejs is incompatible with Heroku. It's using raw sockets, while Heroku only provide HTTP access.
You can deploy shadowsocks-nodejs on a VPS with all the freedom of using raw sockets, or use shadowsocks-dotcloud if you want a free proxy.
EDIT:
The reason why there is no shadowsocks-heroku is that Heroku does not have websocket support.

Look this:
shadowsocks-heroku is a lightweight tunnel proxy which can help you get through firewalls. It is a port of shadowsocks, but through a different protocol.
shadowsocks-heroku uses WebSockets instead of raw sockets, so it can be deployed on heroku.
Notice that the protocol is INCOMPATIBLE with the origin shadowsocks.
https://github.com/mrluanma/shadowsocks-heroku

Related

mup deploy error - x Start Meteor: FAILED

On Windows 10 PowerShell as admin, trying to deploy a Meteor app using mup, onto a VPS Ubuntu 20.04.2 LTS, all went good but failed to start meteor, as show in the bottom of the print out. I "think" that it is because this sentence at the end;
Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use.
Server reports:
root#server:~# netstat -tulpn | grep --color :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 231/apache2
Any idea how to fix this issue where I need Apache to be running as well as nodeJs? Thank you
Update:
The following is the output of mup deploy --verbose, followed by the file mup.js
C:\my-app-dir\.deploy>mup deploy --verbose
Active Connections
Proto Local Address Foreign Address State
TCP 127.0.0.1:49675 LAPTOP-OLT811G5:49676 ESTABLISHED
TCP 127.0.0.1:49676 LAPTOP-OLT811G5:49675 ESTABLISHED
TCP 127.0.0.1:50151 LAPTOP-OLT811G5:50152 ESTABLISHED
TCP 127.0.0.1:50152 LAPTOP-OLT811G5:50151 ESTABLISHED
TCP 127.0.0.1:50154 LAPTOP-OLT811G5:50155 ESTABLISHED
TCP 127.0.0.1:50155 LAPTOP-OLT811G5:50154 ESTABLISHED
TCP 127.0.0.1:50160 LAPTOP-OLT811G5:50161 ESTABLISHED
TCP 127.0.0.1:50161 LAPTOP-OLT811G5:50160 ESTABLISHED
TCP 127.0.0.1:52367 LAPTOP-OLT811G5:52368 ESTABLISHED
[185.148.129.235] - Pushing Meteor App Bundle to the Server: SUCCESS
[185.148.129.235] - Prepare BundlePTOP-OLT811G5:52800 ESTABLISHED
Updating base image52800 LAPTOP-OLT811G5:52799 ESTABLISHED
node-12-base: Pulling from abernix/meteord811G5:55366 ESTABLISHED
Digest: sha256:79c9c29c028fd72320fa1af5e2bab1147db3c206a9d807e9bdb3fb2110660c1a
Status: Image is up to date for abernix/meteord:node-12-baseLISHED
docker.io/abernix/meteord:node-12-base-OLT811G5:60241 ESTABLISHED
Preparing for docker build LAPTOP-OLT811G5:64587 ESTABLISHED
Creating Dockerfile64587 LAPTOP-OLT811G5:64586 ESTABLISHED
Finished creating Dockerfile LAPTOP-OLT811G5:65122 ESTABLISHED
Building image.0.1:65122 LAPTOP-OLT811G5:65121 ESTABLISHED
Sending build context to Docker daemon 128.6MB:65151 ESTABLISHED
Step 1/7 : FROM abernix/meteord:node-12-base1G5:65150 ESTABLISHED
# Executing 1 build trigger 40.119.211.203:https ESTABLISHED
---> Using cache0.67:52400 142.250.4.188:5228 ESTABLISHED
---> 65200bf0c802.67:52422 40.119.211.203:https ESTABLISHED
Step 2/7 : RUN mkdir /built_app || true216-3-76:https ESTABLISHED
---> Using cache0.67:52447 syd15s17-in-f3:https ESTABLISHED
---> 641135f006a7.67:52449 syd09s14-in-f14:https ESTABLISHED
Step 3/7 : ARG ROOT_URL="http://185.148.129.235.static.a2webhosting.com"
---> Using cache0.67:52625 151.101.193.69:https ESTABLISHED
---> 51449bdf1771Documents\meteor\apps\audio\.deploy> mup deploy --verbose
Step 4/7 : ARG MONGO_URL="mongodb://mongodb:27017/audio"
---> Using cache
---> 9e90ec530e62Pushing Meteor App
Step 5/7 : ARG MONGO_OPLOG_URL="mongodb://mongodb/local"ver
---> Using cache
---> be34137de50b
Step 6/7 : COPY ./ /built_app
---> Using cache
---> c23d46e03e72
Step 7/7 : RUN cd /built_app/programs/server && npm install --unsafe-perm
---> Using cache
---> fccd4584401f
[Warning] One or more build-args [NODE_VERSION] were not consumed
Successfully built fccd4584401f
Successfully tagged mup-audio:build
real 0m9.804s
user 0m0.769s
sys 0m1.010s
Tagged latest
Deleted Images:
deleted: sha256:e869f38ad6f15504fdacb6c286dd7904521f4bf2eb00f699fdefb4fa4d4857e1
deleted: sha256:538b72c0548dcc8e1def78d335a34e448d611ed55105cfcd132f1dc7bfe12ac7
deleted: sha256:16b87889c911fdaeb4225509b676468f9c7df9208fd3e17c075c08646b840c51
deleted: sha256:f2b507302cb528f88d72a8837d74b1d523f60426b0dda43fcb0369f9bf1eef27
Total reclaimed space: 139.4MB
[185.148.129.235] - Prepare Bundle: SUCCESS
Started TaskList: Configuring App
[185.148.129.235] - Pushing the Startup Script
[185.148.129.235] - Pushing the Startup Script: SUCCESS
[185.148.129.235] - Sending Environment Variables
[185.148.129.235] - Sending Environment Variables: SUCCESS
Started TaskList: Start Meteor
[185.148.129.235] - Start Meteor
using image
removing last
Image mup-audio:latest
Volume
Removing docker containers. Errors about nonexistent endpoints and containers are normal.
audio
Error response from daemon: endpoint audio not found
Error: No such container: audio-frontend
Error response from daemon: endpoint audio-frontend not found
Error: No such container: audio-nginx-letsencrypt
Error response from daemon: endpoint audio-nginx-letsencrypt not found
Error: No such container: audio-nginx-proxy
Error response from daemon: endpoint audio-nginx-proxy not found
Finished removing docker containers
e63e684acf2ba89117a8ee7c4a53c28ca08cd5fdeacc8c7b368689fcd36172b1
docker: Error response from daemon: driver failed programming external connectivity on endpoint audio (6dcafd574d2116c25d289cc71e15c41112b53a049a52c6481ecd20e51ec8414c): Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use.
[185.148.129.235] x Start Meteor: FAILED
------------------------------------STDERR------------------------------------
Removing docker containers. Errors about nonexistent endpoints and containers are normal.
Error response from daemon: endpoint audio not found
Error: No such container: audio-frontend
Error response from daemon: endpoint audio-frontend not found
Error: No such container: audio-nginx-letsencrypt
Error response from daemon: endpoint audio-nginx-letsencrypt not found
Error: No such container: audio-nginx-proxy
Error response from daemon: endpoint audio-nginx-proxy not found
Finished removing docker containers
docker: Error response from daemon: driver failed programming external connectivity on endpoint audio (6dcafd574d2116c25d289cc71e15c41112b53a049a52c6481ecd20e51ec8414c): Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use.
------------------------------------STDOUT------------------------------------
using image
removing last
Image mup-audio:latest
Volume
audio
e63e684acf2ba89117a8ee7c4a53c28ca08cd5fdeacc8c7b368689fcd36172b1
------------------------------------------------------------------------------
******************************************************************************
//mup.js
module.exports = {
servers: {
one: {
host: '185.148.129.235',
username: 'root',
password: 'abcdefghij',
opts: {
port: 7822
}
}
},
app: {
name: 'audio',
path: '../',
servers: {
one: {},
},
buildOptions: {
serverOnly: true,
},
env: {
ROOT_URL: 'http://185.148.129.235.static.a2webhosting.com',
MONGO_URL: 'mongodb://mongodb/meteor',
MONGO_OPLOG_URL: 'mongodb://mongodb/local',
},
docker: {
image: 'abernix/meteord:node-12-base',
},
enableUploadProgressBar: true
},
mongo: {
version: '3.4.1',
servers: {
one: {}
}
},
};
Since the Ubuntu VPS had Apache2 server listening on port 80, and mup makes the same port number for the docker-containing-meteor-app to listen on. I needed to stop the Apache2 systemctl stop apache2, then mup deploy worked and now the meteor app is accessable on the browser.
Now I need to find out how to use nginx as a proxy for the meteor app.

Run React application in vm azure

I want to run my react application on azure's virtual machine. I started my application in azure's vm but when I go to public url (DNS) of vm it says site can't be reached.
This is what I did to start my project in vm
I ran command ssh a********#52.*..***
After entering vm, I cloned the git project (React nodejs project)
I then install all the packages like npm, node and yarn, important to my project
I then ran gulp command. My project gets compiled successfully
Now, I tried accessing public url (DNS) of my azure's vm
Expected Result: I should be able to see my application page when DNS accessed
Result: Site cannot be reached
This is the serving part of my server file in project
const PORT = (process.env.PORT || 4200);
const runServer = (app)=> {
app.listen(PORT, ()=> {
debug(`Listening on http://localhost:${PORT}`);
if (__DEV__)
debug(`HMR on http://localhost:${config.BS_PORT}`);
});
}
runServer(app);
I started my application in azure's vm but when I go to public url
(DNS) of vm it says site can't be reached.
Can you access this site with localhost? Please test it in your Azure VM, to make sure this service running in the correct port.
We should add port 4200 to Azure NSG (Network security groups) inbound rules.
We can follow this article to add port to NSG inbound rules.
By the way, if you are create a classic VM, we should follow this article to add port 4200 to VM's endpoints.
Also we should check Linux firewall settings, make sure the firewall will not block port 4200.
Finally, we can use telnet to test the network connection.
Update:
We can use netstat -ant | grep 4200 to check the service is running or not.
For example, SSH service listen on port 22:
jason#jasonvm:~$ netstat -ant | grep 22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 104 10.0.0.4:22 167.220.255.8:57001 ESTABLISHED
tcp 0 0 10.0.0.4:58122 52.239.153.36:443 TIME_WAIT
tcp 0 0 10.0.0.4:40922 168.63.129.16:80 TIME_WAIT
tcp6 0 0 :::22 :::* LISTEN
Also we can use telnet to test it, we can install telnet on your local PC, and run this command in CMD, like this telnet vmpublicIP 4200.
If your service listen on port 4200 and it run correctly, we can use this command to access it:
curl localhost:4200

launching angular and node separately but with connection to each other

So just for the testing purposes in production I had to split my frontend client written with angular 1.x and my node backend server code. Client uses api function provided by node but they are running on the different servers on my local machine. I set up my node server for running on port 5000 and when it's running my angular server gives me information that it has to move to port 5001 because port 5000 is already occupied.
How can I launch both of the servers and force them to share API functions on my local machine?
For the angular I use 'serve' -> https://github.com/angular/angular-cli/wiki/serve
you just need to change port for your client side,
for this, edit your angular-cli.json
{
..............
"defaults": {
"styleExt": "css",
"component": {},
"serve": {
"port": 5001
}
}
.................
}
when you do ng serve , it will run your angularjs server on port 5001
This is not an answer but since I couldn't add comments I had to write here.
If you are already using Vagrant then disregard the rest of this post.
This is just an option that may allow you to use both applications on the same port by setting up a vagrant instance.
Setup Vagrant for your node application. Configure the Vagrantfile to forward host:5001 to guest:5000.
config.vm.network :forwarded_port, guest: 5001, host: 5000
You can continue hosting the angular application on your host(localhost) machine. Requests to your API can then be forwarded to the the vagrant instance.
If your angular app and api are already separated by a different domain, you can then update your host file on the local machine to rewrite domain requests to your vagrant machine.

Can't get socket.io to work on server, while running fine locally

This code is running fine with the node.js server running locally:
Server:
var client = require('socket.io').listen(3001).sockets;
Client HTML:
<script src="http://localhost:3001/socket.io/socket.io.js"></script>
Client Javascript:
var socket = io.connect('http://localhost:3001');
Then I moved the server.js to my ubuntu server which has node and socket io installed, using the same code, and started it without error.
Clientside I changed the local html/javascript file from localhost:3001 to ServerIP:3001 and it just doesn't work anymore. When I check firebug, I can see it never finishes trying to GET http://ServerIP:3001/socket.io/socket.io.js. It does not fail, just never finishes.
What did I do wrong? Thank you.
This is most likely a firewall issue.
Allow connections on port 3001 using the following (if you use iptables)
iptables -A INPUT -p tcp --destination-port 3001 -J ACCEPT
Than try again

How to access remote node.js app in browser, not on localhost

I'm trying to set up a simple "Hello world" node.js app.
I've created the following index.js file:
var app = require("express")();
var http = require("http").Server(app);
app.get("/", function(req, res){
res.send("<h1>Hello worlddddd</h1>");
});
http.listen(8080, function(){
console.log("listening on *:8080");
});
When I open up my local console, and perform node index.js, I get the message "listening on *:8080", as expected. I point my browser to localhost:8080, and I see the HTML page saying "Hello worlddd", as desired.
Now, I'm trying to do the same on my Virtual Private Server, so I can access the same app from different computers, but all I get is connection timeouts. I've followed these steps:
Install node.js on my VPS
Install express via npm install --save express#4.10.2
Upload my index.js file to the var/www/html folder on my server with IP 192.123.123.12 (an example, this isn't my real IP).
Access the server via PuTTY, and run node index.js, where I get "listening on *:8080", so I know node.js is working.
Now I point my browser to http://192.123.123.12:8080 and after about 20 seconds, I get the browser error: "The connection has timed out".
I've tried listening to port :80 instead, but I get the error that this port is already in use.
Does anybody know what I'm doing wrong? Am I using the wrong port? Am I pointing to the wrong URL? Do I need to modify my server preferences? (running Apache on CentOS). I've only found dozens of tutorials that teach you how to run a node.js app on your local computer(pointing the browser at localhost:8080), but I need it to run on my remote server so multiple computers can access the same app.
The issue is that your current filters (iptables) block traffic unless you explicitly allow it.
You just need to open port TCP 8080 inbound, and you should be able to reach your node.js server!

Categories

Resources