解决Remix Web IDE 无法本地连接的问题
问题描述
安装完remixd和remix-ide后,参考网上教程,准备将文件夹共享出来,在remix 浏览器IDE中进行本地连接,输入一下命令
remixd -s E:\share_file
结果报错
[ERR] URL Remix IDE instance has to be provided
本以为不是什么大问题,准备在网上搜一下,竟然没有找到一篇文章讲这个问题,不知道是别人都没有遇到还是怎么回事,于是去谷歌了一下,也只有一篇帖子,有图为证
而且第一篇帖子里说是要“update package.json”,完全不是这回事。
问题解决
在网上找到了各种相关帖子,发现没有一个能够解决问题,那就去看看源代码吧。
找到了GitHub上remixd的介绍文档,如下
Usage: remixd -s <shared folder>
Provide a two-way connection between the local computer and Remix IDE.
Options:
-s, --shared-folder <path> Folder to share with Remix IDE
-m, --mist start mist
-g, --geth start geth
-p, --dev-path <dev-path> Folder used by mist/geth to start the development instance
-f, --frontend <front-end> Folder that should be served by remixd
-p, --frontend-port <front-end-port> Http port used by the frontend (default 8082)
-a, --auto-mine mine pending transactions
-r, --rpc <cors-domains> start rpc server. Values are CORS domain
-rp, --rpc-port rpc server port (default 8545)
-h, --help output usage information
除了 -s 共享文件夹的命令外,其他好像都没有啥关系,抱着死马当活马医的态度,试了试 -h 命令
PS E:\share_file> remixd -h
Usage: remixd -s <shared folder>
Provide a two-way connection between the local computer and Remix IDE
Options:
--remix-ide <url> URL of remix instance allowed to connect to this web sockect connection
-s, --shared-folder <path> Folder to share with Remix IDE
--read-only Treat shared folder as read-only (experimental)
--vyper Run a local vyper compiler
-m, --mist start mist
-g, --geth start geth
-p, --dev-path <dev-path> Folder used by mist/geth to start the development instance
-f, --frontend <front-end> Folder that should be served by remixd
-p, --frontend-port <front-end-port> Http port used by the frontend (default 8082)
-a, --auto-mine mine pending transactions
-r, --rpc <cors-domains> start rpc server. Values are CORS domain
-rp, --rpc-port rpc server port (default 8545)
--profiler start profiler service
-h, --help output usage information
Example:
remixd --dev-path /home/devchains/chain1 --mist --geth --frontend /home/frontend --frontend-port 8084 --auto-mine
出来上面的内容,总算看到了跟 ** URL of remix instance**有关的命令,继续试呗
PS E:\share_file> remixd --remix-ide 127.0.0.1:8080
[WARN] You may now only use IDE at 127.0.0.1:8080 to connect to that instance
提示说只能在127.0.0.1:8080里使用IDE去连接这个实例,反正没有报错,那就继续,在终端里启动remix IDE。
PS E:\share_file> remix-ide
在浏览器里输入127.0.0.1:8080后就打开了remix IDE,试试本地连接,成功!!!
power shell里面也显示连接被接受
PS E:\share_file> remix-ide
setup notifications for E:\share_file
Starting Remix IDE at http://localhost:8080 and sharing E:\share_file
Tue Oct 30 2018 21:16:31 GMT+0800 (中国标准时间) Remixd is listening on
Tue Oct 30 2018 21:16:37 GMT+0800 (中国标准时间) Connection accepted.
其他问题
本来到此就应该结束了,但是我之前用过localhost:8080来打开remix IDE本地连接,于是想看看换个URL会不会成功。
PS E:\share_file> remixd --remix-ide "localhost:8080"
[WARN] You may now only use IDE at localhost:8080 to connect to that instance
在浏览器中打开remix IDE,本地连接失败!
然后,我又试了试官网地址
PS E:\share_file> remixd --remix-ide http://remix.ethereum.org/
[WARN] You may now only use IDE at http://remix.ethereum.org/ to connect to that instance
直接通过官网连接打开remix IDE,结果本地连接还是失败!
PS E:\share_file> remix-ide
setup notifications for E:\share_file
Starting Remix IDE at http://localhost:8080 and sharing E:\share_file
Tue Oct 30 2018 20:40:53 GMT+0800 (中国标准时间) Remixd is listening on 127.0.0.1:65520
Tue Oct 30 2018 20:41:30 GMT+0800 (中国标准时间) Connection from origin http://localhost:8080 rejected.
Tue Oct 30 2018 21:10:08 GMT+0800 (中国标准时间) Connection from origin http://localhost:8080 rejected.
^C终止批处理操作吗(Y/N)? y
PS E:\share_file> remix-ide
setup notifications for E:\share_file
Starting Remix IDE at http://localhost:8080 and sharing E:\share_file
Tue Oct 30 2018 20:38:43 GMT+0800 (中国标准时间) Remixd is listening on 127.0.0.1:65520
Tue Oct 30 2018 20:38:57 GMT+0800 (中国标准时间) Connection from origin http://localhost:8080 rejected.
Tue Oct 30 2018 20:39:06 GMT+0800 (中国标准时间) Connection from origin http://localhost:8080 rejected.
Tue Oct 30 2018 20:39:09 GMT+0800 (中国标准时间) Connection from origin http://localhost:8080 rejected.
Tue Oct 30 2018 20:39:18 GMT+0800 (中国标准时间) Connection from origin http://localhost:8080 rejected.
Tue Oct 30 2018 20:39:27 GMT+0800 (中国标准时间) Connection from origin http://localhost:8080 rejected.
其他两个地址的连接请求都失败了,不知道与Remixd 的监听地址有没有关系,期待大家的解答!