有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

WebSocket握手期间发生java错误:意外响应代码:400,带有CoinIMP键

我看到了很多与此错误相关的帖子,但看起来解决方案与代码本身有关

我试图为我的论文做一个关于比特币挖掘的预测,我在研究过程中收到了这个错误。开始()。这是我的代码,非常简单:

<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>

你能解释一下我的错误与什么有关吗?谢谢


共 (1) 个答案

  1. # 1 楼答案

    在做了一些研究之后,我在其中一个响应标题中发现了以下状态代码:

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

    如果您有一个file:URL方案,那么CoinImp似乎不允许您访问API。如果您只是双击包含代码的HTML文件,它将在浏览器中以file:URL模式打开

    使用类似于npmPythonXampp的东西在本地计算机上托管HTML文件,以便您可以使用httphttps访问它,然后CoinImp应该停止阻止您