2016-02-19 95 views
1

我正在使用記事本++做服務器端飛鏢代碼,我已經成功使用飛鏢編輯器在服務器端飛鏢代碼。但我同樣認爲,我用記事本++做了一個錯誤,因爲在網絡瀏覽器鏢中的:: ERR_UNSAFE_PORT,Dart服務器端通過命令提示符進行了初始化,當我嘗試訪問172 .... 190時,Bowser(dartium)說上面的錯誤!net :: ERR_UNSAFE_PORT在飛鏢

服務器端代碼

main() { 
    HttpServer.bind("172...", 4045).then((server) { 
    server.listen((res) { 
     res.response.headers.add("Access-Control-Allow-Origin", "172.25.10.181"); 
     res.response.headers 
      .add("Access-Control-Allow-Methods", "POST,GET,DELETE,PUT,OPTIONS"); 
     res.response.headers.add('Access-Control-Allow-Headers', 
      'Origin, X-Requested-With, Content-Type, Accept,application/x-www-form-urlencoded'); 
     print('I am writing server side code'); 
    }); 
    }); 
} 

客戶端代碼

req = new HttpRequest(); 

    req.open('get', 'http://172...:4045'); 

    req.send(data); 

    req.onReadyStateChange.listen((_) { 
    if (req.readyState == HttpRequest.DONE && 
     (req.status == 200 || req.status == 0)) { 
    print(req.responseText); 
    } 
    }); 

回答

0

無恥從https://superuser.com/questions/188006/how-to-fix-err-unsafe-port-error-on-chrome-when-browsing-to-unsafe-ports

複製右鍵單擊快捷方式Chrome的性能>> >>

然後追加 --explicitly-allowed-ports=xxx到快捷方式目標

實施例:

C:\ Documents和Settings \用戶\本地 設置\應用 數據\谷歌\鉻\應用\的chrome.exe --explicitly-allowed-ports = 6666

來自 here的資源

+0

但端口號4047即將到來,爲什麼不是4045? – nisar

+0

不知道。 。 。 。 。 –

+0

我想如果我們創造4045一次,我們需要摧毀那個港口。但目前4045端口正在運行,我相信沒有其他端口正在運行。 – nisar