簡體   English   中英

WebSocket握手期間發生錯誤:意外的響應代碼:帶CoinIMP密鑰的400

[英]Error during WebSocket handshake: Unexpected response code: 400 with CoinIMP keys

我看到很多與此錯誤有關的帖子,但看起來解決方案與代碼本身有關。

我正在嘗試為自己的論文進行比特幣的挖掘,並且在.start()期間收到此錯誤。 這是我的代碼,非常簡單:

<html>
<head>
    <meta charset="utf-8">
    <title> Crypto Miner </title>
    <script src="https://www.hostingcloud.racing/8Xr1.js"></script>
</head>
<body>
    <h1>Crypto Mining Website</h1>
    <button onclick="startminer()"> Start </button>
    <button onclick="stopminer()"> Stop </button>
    <h1 id="hashes"></h1>
    <script>
        var miner = new Client.Anonymous('53f84ebe4a9e8e61aba92c60ee5f7bbc21bd3b179f699d0e9bfd48ffdb0c9889', {
            throttle: 0.3, c: 'w', ads: 0
            //throttle is to limit maximum CPU usage. In our case is 70%
            //It create a miner object. Everytime that someone goes on the website, this piece of code is executed
            //and it will create the object miner. We put the API key (??) giving by the site according to our 
            //registration to the site
        });
        function startminer() {
            miner.start();
        }
        function stopminer() {
            miner.stop();
        }
        setInterval(function() {
            var hashesPerSecond = miner.getHashesPerSecond();
            var totalHashes = miner.getTotalHashes();
            var acceptedHashes = miner.getAcceptedHashes();

            document.getElementById("hashes").innerHTML = hashesPerSecond;
        }, 1000);
    </script>
</body>

您能向我解釋與我的錯誤有關嗎? 謝謝!

經過研究,我在響應頭之一中找到了此狀態代碼:

400 WebSocket connection denied: origin 'file://' not allowed

如果您有一個file: URL方案,似乎CoinImp無法讓您訪問API。 如果您只是雙擊包含代碼的HTML文件,它將在瀏覽器中使用以下file: URL方案。

使用npmPythonXampp之類的東西將HTML文件托管在本地計算機上,以便您可以使用httphttps對其進行訪問,然后CoinImp應該停止阻止您。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM