IPFS Swarm Connect

Hello

I am able to connect 2 peers using Swarm Connect. what is the command to send messages between these 2 connected peers. I think I am missing some commands. If anyone can help

Thanks in advance

Regards
Ashok

If you want to send messages between nodes, you’re better off using libp2p directly (https://github.com/libp2p/go-libp2p or https://github.com/libp2p/js-libp2p).

You can mount custom protocols using the ipfs p2p command, but I’d still recommend using libp2p directly:

1 Like

Thanks Steven

That was great help. Can communicate amongst peers using libp2p

Regards

Ashok Iyengar

I am using ipfs swarm connect to connect two nodes connected to different networks. The nodes are approximately 24 km apart. But when I type the command
ipfs swarm connect /ip4/external_ip_of_the_node/tcp/9001/ipfs/peer_id_of_the_node
where the external ip of the node has been found from https://whatismyipaddress.com/ this error is displayed:

Error: connect Qm_peer_id failure: failed to
** dial : all dials failed**
** * [/ip4/external_ip/tcp/9001] dial tcp4 0.0.0.0:4001->external_ip:9001:**
i/o timeout

But I don’t think there is any problem with the port as I was able to connect to the node when two nodes were connected to the same network using the ip address of the localhost. In the firewall settings,ipfs.exe is unblocked. We have even added our address in the announce array in ipfs config as suggested inhttps://stackoverflow.com/questions/49347185/ipfs-swarm-connect-connect-failure-dial-attempt-failed-context-deadline-exc?rq=1 and also added one of the node’s address in the bootstrap list of both nodes. Still the error was not corrected. I don’t know what else to do. I need suggestion.

Can you check if port 9001 is open on firewall to accept connection.

Can you tell how to check that?I am a novice in this subject. Actually, when the nodes were connected to the same network,the connection was successful using port 9001 only. So I thought there is no problem with the port. Also I have tried random higher numbered ports for connection with this node as mentioned in one article.
Both the nodes have ipfs version 0.4.23 and Windows operating system.

On your windows machine with public IP run this command on dos prompt
netstat -an |find /i “listening” and check if port 9001 is available for TCP to listen

Thank you very much for answering. The node with which I am trying to connect was using port 9001 for communication and I was using port 8080. Also, we had put these port numbers along with the ip address in the announce array. I noticed that we were using the same ports as the gateway server of ipfs i.e the gateway server of our ipfs nodes were listening on the same port. This came as the netstat command output in the node using port 9001 I am trying to connect to:
C:\Users\user>netstat -an|find "9001"
** TCP 127.0.0.1:9001 0.0.0.0:0 LISTENING**
Same output came for my node using port 8080.
I again tested connecting to the other node using the default port 4001 instead of 9001 but the same error was displayed:
Error: connect Qm_peer_id failure: failed to
** dial : all dials failed**
** * [/ip4/external_ip/tcp/4001] dial tcp4 0.0.0.0:4001->external_ip:4001:**
i/o timeout
When we checked netstat for port 4001,this was displayed:
TCP 0.0.0.0:4001 0.0.0.0:0 LISTENING
I can’t understand the problem with using these ports. Should I use some other port?Somewhere I read that sometimes ports need to be forwarded but I don’t know how to do that. How to solve this?

Rita

This might sound a bit lame but can you run this command on your dos

" telnet external IP and port and see if you are able to get a connection

I tried telnet using the external ip and port of the node but the connection failed. Error message was displayed showing failed opening connection. Then I also tried forwarding port 4001 on windows firewall by adding inbound rules on both nodes and also added another rule that allows our particular external ip on both nodes. Still telnet failed,connection was not successful. So is there some way out of this or not?Do we need to change any other settings?

The issue is likely our NAT/router, not your local computer’s firewall. go-ipfs tries to ask these devices to forward a port, but that doesn’t always work.

Thank you for the reply.