Code Monkey home page Code Monkey logo

Comments (9)

marcelklehr avatar marcelklehr commented on August 11, 2024

I'm not sure exactly what you tried without the code / terminal input and output, but I can give you a rough description of how it is supposed to work:

The idea is that the code is the same for both nodes. Thus, the seed address is hardcoded and is used to determine if the currently running node is a seed or needs to connect to the seed.

Also, the ip addresses you use are crucial to the ability of the nodes to connect: You should use an ip address that is not shadowed by a network of the other node (i.e. as public an address as possible). However, obviously if you're behind a router or firewall, those need to be configured accordingly. Smokesignal's work begins above tcp/ip ;)

from smokesignal.

dhasl002 avatar dhasl002 commented on August 11, 2024

Thank you for the quick reply. This is the only code that I have changed:

var node = smoke.createNode({
port: parseInt(process.argv[2]) || 5000
, address: '128.82.26.203'
, seeds: [{port: 5000, address:'128.82.22.40'}] //<-- You may need to change this address!})

The address will be different for both computers. I simply google the ip address and hard code it currently. Originally, I would make the seed the address and port of the peer I am attempting to connect to. Are you suggesting that the seed should be the port and address of the first computer to connect to the network?
Thank you for your help!!

from smokesignal.

marcelklehr avatar marcelklehr commented on August 11, 2024

Ah, I see. The problem with dynamic networks is that you need to know a node to connect to the network, but when the network fluctuates it's hard to keep track of nodes you might use to join. To solve this problem, there are seeds, nodes that are guaranteed to be available by some entity and that can be used reliably to enter the network. In smokesignal seeds are used for some additional magic to avoid netsplits, where a part of the network completely separates from the rest.

So, tl;dr: The value of seeds should be the same for all nodes. Smokesignal will figure out, if it's a seed or not and act accordingly.

from smokesignal.

dhasl002 avatar dhasl002 commented on August 11, 2024

So to summarize, if I want to add two computers to the network, the seed for both should be a separate third ip address? Would this third ip address need to also be running the script?

Additionally, I believe my problem could be related to the ports I am attempting to use. Using this port scanner, I have learned that the ports I am attempting to use are stealthed. Could this be the source of my problem?

Lastly, if I am using the same wifi to connect the computers, could this be a problem? In this case, both computer have the same ip address.

Again, thank you for your help!

from smokesignal.

marcelklehr avatar marcelklehr commented on August 11, 2024

So to summarize, if I want to add two computers to the network, the seed for both should be a separate third ip address? Would this third ip address need to also be running the script?

Half-correct, but we're getting there :) You can connect two nodes, but one of them must be a seed and thus be in the array of seeds on both sides.

Additionally, I believe my problem could be related to the ports I am attempting to use. Using this port scanner, I have learned that the ports I am attempting to use are stealthed. Could this be the source of my problem?

Lastly, if I am using the same wifi to connect the computers, could this be a problem? In this case, both computer have the same ip address.

Yes, if a node is behind a firewall like a router usually has one, then you cannot access it from the outside. That's what the firewall is for. You could open the port in the configuration of your router, but then you'd still have the NAT functionality of your router as a probem: All computers behind the router look like the same computer from the outside. But as long as all your nodes are on the same network, like in your case, you can simply use the internal addresses of your home network for the nodes. I.e. for me this is something like 192.168.xx.xx

from smokesignal.

dhasl002 avatar dhasl002 commented on August 11, 2024

Hmm, I still cannot get it to work.

This would be the code for the computer I would run first.
var node = smoke.createNode({
port: parseInt(process.argv[2]) || 5000
, address: '216.54.1.206'
, seeds: [{port: 5000, address:'216.54.1.206'}] //<-- You may need to change this address!
})

This is the code for the computer I would run second.
var node = smoke.createNode({
port: parseInt(process.argv[2]) || 5001
, address: '216.54.1.206'
, seeds: [{port: 5000, address:'216.54.1.206'}] //<-- You may need to change this address!
})

I believe I have done everything exactly as you have suggested. No other code was changed from the original. Both computers say that they are connecting..., but nothing about being connected is ever printed to the screen.

from smokesignal.

marcelklehr avatar marcelklehr commented on August 11, 2024

You have entered the same address on both computers. I'm sorry if that wasn't clear from my explanation: Let's say Computer A should also be seed, then in the code on that computer you should enter address: A and seeds: [{port: ..., address: A}]. Computer B is going to be a normal peer, so it gets address: B, but the same seeds value: seeds: [{port: ..., address: A}] ;)

Edit: Unless you are attempting to use the public-facing ip to connect them... This seems to not work in some cases, for me it also doesn't work at home :/

from smokesignal.

dhasl002 avatar dhasl002 commented on August 11, 2024

I have been using the public facing ip address. Will this not work?

From your explanation originally, i thought computers on the same network would have the same address. Should i be using a more specific address?

From your edit, i am a little confused. So this code only works when both computers are on different networks?

from smokesignal.

marcelklehr avatar marcelklehr commented on August 11, 2024

I'm sorry to have confused you. It seems a deeper understanding of the way IP networks work is necessary.

You computers of course have different IP addresses on some level, because they are not the same computer. However, your router regulates access to your private network using a technique called NAT. So, you can use the local/private ip addresses to connect your computers as long as every peer of the smokesignal network is also inside that same LAN (otherwise the ip addresses just won't work). If you want to use the public facing ip, you need to make sure each actual peer behind the router gets their own port, as you have done correctly. Your router must also support NAT loopback, though, for the two peers behind it to be able to reach each other.

Edit: I recommend trying it with private IP addresses first. If you want to use public addresses at some point, you can check if your router supports NAT loopback, by setting up some http server, for example, have the router forward some port to that server, google your ip address and try to access the http server with that address in your browser from a computer within the network (for example, the one you're running the server on). Uff. Sounds more complicated than it is. :D

from smokesignal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.