I'm running a game which contains a server.js backend (which is hosted and run on my localhost), and the frontend is on a github website. The github page connects to the server on my localhost through the config which points to 127.0.0.1. I realize that I will be able to play this from my localhost this way, but will other people be able to?
Basically the index.html connects to the visitor's localhost to look for the running server.
A visual representation (sort of):
[nullwalker.github.io/index.html] ----> [localhost(127.0.0.1)/server.js]
What should I do to allow myself to play from the computer that's hosting the server backend as well as others being able to play?
You would need to host it in a live environment. There are ways via port forwarding to use your computers ip (gateway) to allow others to connect, however typically ISP's will try to stop you from using your dynamic IP statically. Safest bet is to launch a cheap VPS and host it there.
http://www.howtogeek.com/66214/how-to-forward-ports-on-your-router/
This article seems to explain port forwarding well enough.
As for the VPS, you can find extremely cheap ones really easily, if you do not expect a lot of players it should be fine, if you expect more then using your own connection is dangerous.
unless they have the same server running on their localhost, no. And they almost surely don't. You should get a host (digitalocean.com is very popular and good, but there are many others), and then run it there and connect to that instead of localhost
Related
I am running a web application on Ubuntu, and serve it with http-server. Because there are more instances of this application running (with some differences between the instances), most of them have a portnumber behind them. However, I would like to have one root web application which now runs on example.com:1234 to be accesible on example.com
Are there any other ways to make this possible?
I have tried using the --proxy flag of http-server, but I can't seem to make the URL work. There is another package called http-proxy, but this would take some time to make it work (extra code). I hope there is a simpler solution than installing another node package.
Well I don't think you could change the port number, but if you want to change the host name you could just do the following,
/etc/hosts (or it's equivalents on other OS's) is used to resolve hostnames to some ip without asking to dns servers.
You can use in your /etc/hosts:
127.0.0.1 myserver.com
And then open http://myserver.com:3333 in your browser and it will connect to 127.0.0.1 to 3333 port.
I am talking about things locally. Otherwise host your server and bind it using ngnix.conf or IP tables.
If root web application is already running, if it facilitates changing port number you can change that to port number example.com:80, so that it will automatically picked up when you hit the URL with example.com.
I am trying to develop a word addin. It will provide corrections for a word based on the context. The language will be Bengali.
My idea is that there will be a python server in localhost. Yes it will run on the localhost. Otherwise if it is a central server there will be too much requests. So somehow (maybe through an exe file I will run the server on in localhost) I will make the server run on localhost. The .exe file can be distributed to anyone and when he/she runs it, it will run on their localhost and then he/she can use the word addin (that I am developing) to call to the localhost to get the desired output. It should be noted that, the platform will be windows.
But the problem is word JavaScript api doesn't let me call to the localhost in http. It only can call to https. But localhost isn't https. If there's anyway I can call the word api in http localhost? Also, as I am looking to make a complete product, I am trying to skip OS related configurations. For example, making localhost certified. Because, when the application (python server) will be transferred, I don''t know how and if it is possible to run script in others' windows OS and make their localhost certified. So, it will be very helpful to make word api just call to my localhost using http (or atmost https://localhost) and not some https://somedomainname.com.
For coding environment to develop the word addin, I am using script lab. So, it will be better to find a solution that will be supported by script lab.
There are a few problems with this approach.
For one - you will never pass the validation, when you're trying to call the localhost - since it will fail by default and you'll be asking the users to install an additional software to support your JS add-in. The add-ins should work standalone.
If there's anyway I can call the word api in http localhost?
No - there isn't in this context. Your final manifest URL's need to be https and they should be externally available.
I am trying to skip OS related configurations. For example, making
localhost certified. Because, when the application (python server)
will be transferred, I don''t know how and if it is possible to run
script in others' windows OS and make their localhost certified.
One of the benefits of the Office store is that Microsoft can look after if the add-in the customers are installing (which we're developing) is malicious or not. Trying to say you want to bypass validation doesn't help this case.
My idea is that there will be a python server in localhost. Yes it
will run on the localhost. Otherwise if it is a central server there
will be too much requests.
It should be a central server and you should handle the scalability aspect of it. You might not have a huge number of users as you're imagining to begin with. I'd recommend Heroku - they support python and their first tier is free, you can develop & publish your add-in and once it starts getting significant traffic, you can look into moving it to other places.
I don't know if this question is the most appropriate way to ask it. But I am really confused on how Node.JS works. I consider myself an advance JavaScript user/developer but I cant get a knack on how to implement Node.JS as a replacement for PHP.
I have been used to developing sites with PHP as it's backend. But now I want to change to Node.JS. Now I'm really confused when watching tutorials about node. I've seen that it always needs cli to be open, and when a user visits your site, do they need to enter port number into the URL in order for the node script to work?
Another question (if I hadn't already asked a million of them) is node.js considered safe if I use it as backend and put my Database details into the script? I'm just confused because if you enter the app.js path into the URL, the user can see all it's content not like PHP.
Thank you in advance!
If you are a NodeJS beginner and looking to host your app somewhere I recommend using EvenNode or Heroku to host your simple node applications until you have a better understanding on how NodeJS works.
Some docs on node hosting on these platforms
EvenNode : docs
Heroku : docs
To answer your other questions :
when a user visits your site, do they need to enter port number into the URL in order for the node script to work?
It depends on your setup. You can choose to run your node application server on a specific port or can always opt to run it on port 443 (https) or port 80 (http) and the client certainly wouldn't need to specify a port in the host name.
is node.js considered safe if I use it as backend and put my Database details into the script?
Yes, NodeJS is safe. NodeJS is server side language just like Java, C#, Python, etc. It is safe so long as you don't expose any sensitive data, such as database connection information, publicly. The only reason you can view your app.js via (im assuming the browser) locally is because you are viewing it as a 'file://'. when this code is ran as a server, the server side code will not be viewable to the client.
You want a hosting with root access for Node.js.
So you want a VPS or Dedicated Server at GoDaddy.
The user does — not — have to enter the port always.
If you set it to 80 for http and 443 for https it works so.
You can have the main script in another directory.
Like that it is safe to enter database details.
The user cannot get the script then.
TL;DR
In Javascript, how do you to find the IP of all servers running a specified program on a specified port in the LAN?
Background
I'm writing a server in node.js that is supposed to connect users browsers as controllers to a common device on which a game is running. The browsers are running a web app based on html and Javascript. The connection is based on socket.io.
I'd like for the web app to be able to find all available instances of this server in the LAN in order to create a server list for the user to choose from.
Is there a way to make the server discoverable by the web app on the local network in Javascript, and in that case: how?
Ideas
Have the server broadcast its IP to all devices on the LAN and have the web app listen for these messages (No idea how to do this without node on the client)
Connect to every IP on the network and see if the connection is successful. (Does not seem feasible)
Scan every IP on the network and connect only to those where the port is open. (Once again, no idea how to do this without node on the client and does not seeem feasible either.)
EDIT
The server is supposed to be portable and work independently, without any central system backing it up or providing matchmaking for clients. It is a LAN only server and should work even without internet access.
There is no way for you do this. Sorry. Since there is no exposure to UDP on client-side JavaScript, broadcasting is out of question. Any attempt on massive scanning will quickly raise flags on network monitoring software. You have to use a known address.
Alright, so I had my socket.io server listening on a different port, but in order to get it to work with https, I needed to have it listen without passing in a port (default). (It works fine on a different port loaded with http, but I need it to work on https)
My project was working fine, client could connect and send data fine. However, I moved the site over to my main domain, which has an SSL certificate. The site loads everything via https, so it couldn't load the http version of socket.io.js
However, now that I switched it to just var client = require("socket.io").listen().sockets; instead of listening on a different/specific port , it's still not working. Instead of giving me a connection error, it's not including the file at all.
My fear is that I'd end up needing to remake my whole site to host my files via node.js and I'd rather not have to do that.
I'm not using any other module than mysql-node and socket.io, and I'd prefer to keep it that way if possible. I am new to node.js, so I'm sorry if there's an obvious answer that I'm unaware of.
I looked around, however, and can't seem to find the answer anywhere. Or, at least a clear answer.
Would I be better off using websockets instead of socket.io?
If so, how would I go about doing this? I'd be more willing to remake my node application instead of remaking my site, honestly.
I am including the socket.io.js file in the client-side like so:
<script src="https://mysite/socket-io/socket.io.js"></script>
but of course, 404 since it's not an actual file that's on my apache server. There's no folder/directory named socket-io in my public_html directory, so that makes sense to me.
But, how can I get this to work? Would I need to host my files via node.js or would I be better off using HTML5 websockets? A fairly large demographic of my site's users use mobile devices, so I'd have to be sure it works on mobile as well.
If you're going to use apache to host the socket.io.js file, then you need to put that file on your Apache server at a path that it can be served from by Apache, just like any other web file that you want the Apache server to serve. Or, you can just serve socket.io.js from a public CDN also and use the public CDN URL. It's just a JS file. You can put it anywhere or use any URL that reaches a place where the file will be served from. There are some advantages to letting node.js and socket.io serve it for you because it guarantees that client and server socket.io versions are always in sync, but you don't have to do it that way.
If you are using node.js (which it sounds like you are at least in some capacity), then the socket.io built into node.js will serve the file automatically if you are using node.js to serve your web page too and you've configured socket.io to listen on the same port as your node.js web server. In that case, your webpage and socket.io will use the same port and both will run through the node.js server.
You haven't really explained why you're using both node.js and Apache, how that architecture works and why you're serving some of your site with Apache rather than just using node.js for the whole site as that is certainly the cleaner option with socket.io.
You can use plain webSockets if you want instead of socket.io, but then you will likely have to build some of the socket.io functionality on top of the webSockets (auto-reconnect, message passing, etc...) and using plain webSockets won't really simplify any of the Apache/node.js questions you have. It's trivial to serve up the socket.io.js file to the client using either Apache or node.js and once the client has the file, it is actually more work to use plain webSockets than to use socket.io because of the extra features that socket.io has already built.