1. 程式人生 > >[ERR] URL Remix IDE instance has to be provided 解決辦法

[ERR] URL Remix IDE instance has to be provided 解決辦法

解決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 的監聽地址有沒有關係,期待大家的解答!