简体   繁体   English

WebSocket握手期间发生错误:意外的响应代码:带CoinIMP密钥的400

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

I saw a lot of post related to this error but looks like the solution is related to the code itself. 我看到很多与此错误有关的帖子,但看起来解决方案与代码本身有关。

I'm trying to do a prevision to the mining of a bitcoin for my thesis and I receive this error during the .start(). 我正在尝试为自己的论文进行比特币的挖掘,并且在.start()期间收到此错误。 Here is my code which is really easy: 这是我的代码,非常简单:

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

Could you explain to my to what is related my error? 您能向我解释与我的错误有关吗? Thanks! 谢谢!

After doing some research, I found this status code in one of the response headers: 经过研究,我在响应头之一中找到了此状态代码:

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

It seems like CoinImp does not give you access to the API if you have a file: URL scheme. 如果您有一个file: URL方案,似乎CoinImp无法让您访问API。 If you're just double clicking the HTML file that contains your code, it will open up in your browser with the file: URL scheme. 如果您只是双击包含代码的HTML文件,它将在浏览器中使用以下file: URL方案。

Use something like npm , Python or Xampp to host your HTML file on your local machine so that you can access it using http or https , then CoinImp should stop blocking you. 使用npmPythonXampp之类的东西将HTML文件托管在本地计算机上,以便您可以使用httphttps对其进行访问,然后CoinImp应该停止阻止您。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WebSocket握手期间出错(意外的响应代码:400) - Error during WebSocket handshake (Unexpected response code: 400) Spring,SockJS - WebSocket 握手期间出错:意外响应代码 400 - Spring, SockJS - error during WebSocket handshake: Unexpected response code 400 WebSocket 握手期间出错:意外响应代码:400 Spring 启动 websockets - Error during WebSocket handshake: Unexpected response code: 400 Spring boot websockets 失败:WebSocket 握手期间出错:意外响应代码:302 - failed: Error during WebSocket handshake: Unexpected response code: 302 WebSocket 握手期间出错:意外响应代码:403 - Error during WebSocket handshake: Unexpected response code: 403 失败:WebSocket握手期间出错:意外的响应代码:404 - failed: Error during WebSocket handshake: Unexpected response code: 404 WebSocket握手期间出错:意外的响应代码:404 - Error during WebSocket handshake: Unexpected response code: 404 WebSocket握手期间出错:意外的响应代码:302 - Error during WebSocket handshake: Unexpected response code: 302 java-server websocket失败:WebSocket握手期间出错:意外的响应代码:404 - java-server websocket failed: Error during WebSocket handshake: Unexpected response code: 404 WebSocket与“ ws:// *”的连接失败:WebSocket握手期间出错:意外的响应代码:404 - WebSocket connection to 'ws://*' failed: Error during WebSocket handshake: Unexpected response code: 404
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM