首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ipfsd-ctl生成IPFS守护进程时出现的"POST http://localhost:9090/spawn ERR_CONNECTION_REFUSED“错误

使用ipfsd-ctl生成IPFS守护进程时出现的"POST http://localhost:9090/spawn ERR_CONNECTION_REFUSED“错误
EN

Stack Overflow用户
提问于 2021-02-17 17:21:46
回答 1查看 192关注 0票数 0

我试图使用ipfsd-ctl库使用提供的远程端点从浏览器生成IPFS守护进程。

这就是我指的链接

代码语言:javascript
复制
// Start a remote disposable node, and get access to the api
// print the node id, and stop the temporary daemon

const Ctl = require('ipfsd-ctl')

const port = 9090
const server = Ctl.createServer(port, {
    ipfsModule: require('ipfs'),
    ipfsHttpModule: require('ipfs-http-client')
},
{
    js: {
        ipfsBin: 'path/js/ipfs/bin'
    },
    go: {
        ipfsBin: 'path/go/ipfs/bin'
    },
})
const factory = Ctl.createFactory({
    ipfsHttpModule: require('ipfs-http-client'),
    remote: true,
    endpoint: `http://localhost:${port}` // or you can set process.env.IPFSD_CTL_SERVER to http://localhost:9090
})

await server.start()
const ipfsd = await factory.spawn()
const id = await ipfsd.api.id()

console.log(id)

await ipfsd.stop()
await server.stop()

它显示了“浏览器中未实现的服务器”警告和"POST http://localhost:9090/spawn net::ERR_CONNECTION_REFUSED“错误

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-18 14:14:23

Ctl.createServer启动Ctl.createFactory将连接到的HTTP。正如警告中所说的,“服务器未在浏览器中实现”,您需要在nodejs中运行它,并在浏览器中使用Ctl.createFactory与其交互。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66246962

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档