Is it possible to open websocket connection on go-ipfs node, and how?
I would like to setup something like:
'/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd'
You need:
/dns4 or /dns6 name/ip4/127.0.0.1/tcp/8081/ws/ws here, not /wss -- go-ipfs can't currently do SSL, see the next pointI have a work-in-progress branch which simplifies this a bit, but that's the setup for now.
Ok thanks @lgierth this was helpful:+1:
@lgierth Hi Lars I'm trying to do this to get my js-ipfs browser client directly talking to my go-ipfs node, and this thread is the only place I can find guidance on how to do this. I tried it but it doesn't work, I must be missing a piece.
The go-ipfs node is on AWS and has public IP 18.XXX.XX.XXX and private/internal IP 172.XX.XX.XX.
The node's addresses config looks like this:
"Addresses": {
"API": "/ip4/172.XX.XX.XX/tcp/5001",
"Announce": [],
"Gateway": "/ip4/172.XX.XX.XX/tcp/8080",
"NoAnnounce": [],
"Swarm": [
"/ip4/172.XX.XX.XX/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/172.XX.XX.XX/tcp/4002/ws"
]
},
I addd the /ws address as instructed. I assume this makes the node listen via a web socket on 4002.
I have nginx set up with a certificate made via certbot with the following config:
` server {
listen 80;
server_name mydomain.com;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
proxy_pass http://18.XXX.XX.XXX:4002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
} `
Is this port forwarding being done correctly as you have described?
The last piece of the puzzle is the ipfs-js config in the browser. I've tried adding many addresses in the creation of the node like so:
const node = new IPFS({
config: {
Bootstrap: [
"/ip4/mydomain.com/tcp/443"
],
}
});
But really I don't really know what would go here.
I keep getting "NotFoundError"...but I know for a fact that this hash is on my go-ipfs node.
Your help would greatly be appreciated!!!
Would really appreciate if someone can point to how a client can establish webSocket connection to a node, and gateway. Any examples would be very helpful.
@KrishnaPG please ask on the forums (https://discuss.ipfs.io) and tag me. When you do, please expand on what you mean by "establish a webSocket connection" (connect to the API? gateway? libp2p?).
Most helpful comment
@lgierth Hi Lars I'm trying to do this to get my js-ipfs browser client directly talking to my go-ipfs node, and this thread is the only place I can find guidance on how to do this. I tried it but it doesn't work, I must be missing a piece.
The go-ipfs node is on AWS and has public IP 18.XXX.XX.XXX and private/internal IP 172.XX.XX.XX.
The node's addresses config looks like this:
"Addresses": { "API": "/ip4/172.XX.XX.XX/tcp/5001", "Announce": [], "Gateway": "/ip4/172.XX.XX.XX/tcp/8080", "NoAnnounce": [], "Swarm": [ "/ip4/172.XX.XX.XX/tcp/4001", "/ip6/::/tcp/4001", "/ip4/172.XX.XX.XX/tcp/4002/ws" ] },I addd the /ws address as instructed. I assume this makes the node listen via a web socket on 4002.
I have nginx set up with a certificate made via certbot with the following config:
` server {
listen 80;
server_name mydomain.com;
} `
Is this port forwarding being done correctly as you have described?
The last piece of the puzzle is the ipfs-js config in the browser. I've tried adding many addresses in the creation of the node like so:
const node = new IPFS({ config: { Bootstrap: [ "/ip4/mydomain.com/tcp/443" ], } });But really I don't really know what would go here.
I keep getting "NotFoundError"...but I know for a fact that this hash is on my go-ipfs node.
Your help would greatly be appreciated!!!