Nicehashminer: Old versions triggering "Unable to get NiceHash profitability data".. the cause of the problem is the Invoke call in SetVersionLabel, called from VersionUpdateCallback.

Created on 26 Nov 2017  路  21Comments  路  Source: nicehash/NiceHashMiner

In order to get to the bottom of the "Unable to get Nicehash profitability data" issue with old versions of the software I decided to have a look at this issue myself.

I've discovered that the cause of this problem is completely with NiceHashMinerLegacy, it has nothing to do with CloudFlare, or Internet connectivity or anything else, it is a problem with the NiceHashMinerLegacy code. It is triggered by the "Invoke(d, new object[] {text });" call in SetVersionLabel. If you comment that line out when running an old version then everything works correctly.

If you debug what is happening you will see that if the "VersionUpdateCallback" method detects an old version it then calls SetVersionLabel. SetVersionLabel does the problematic Invoke call. Basically the Invoke call results in the "if (Globals.NiceHashData == null)" test in StartMining() executing before the SMACallback ever has a chance to execute "Globals.NiceHashData = NiceHashStats.AlgorithmRates;".

Now that I've found the problem can a developer actually fix it please.

bug

Most helpful comment

Also, I don't understand why NHML is using "blocking" MessageBoxes to display transient errors.. because these MessageBoxes prevent the application from automatically retrying without user input.

All 21 comments

I commented this line, but I still have the same problem.
actually I just placed return; in the beginning of the method, and compiled.

Please describe the problem you are experiencing, is it the appearance of the "Unable to get NiceHash profitability data" immediately after startup (when running an old version number) or is it something else?

yep.
first its:
loading..
Getting NiseHash SMA information...
NHML required internet connection to run. please ensure...
then, once I click continue, start

Unable to get NH profitability data. blabla

I have been getting the same thing for quite a while now. and its completely random.
sometimes it works, sometimes not.

In my case I wasn't getting the "NHML required internet connection to run. please ensure..." warning message at the beginning, only the "Unable to get NiceHash profitability data" error. And my solution has worked 100% for my particular issue. My main problem is that NHML stops working whenever a new release appears... which is really annoying.

Regarding my exact issue, I'm not sure if the Nicehash API server is always sending the websocket messages in the same order, because if they are random then the application would actually work sometimes if the SMA message is received before the versions message.

I think its just because the nicehash api websocket is down sometime..
even now, when I test http://demos.kaazing.com/echo/index.html

public static string NHM_Socket_Address = "wss://api.nicehash.com/v2/nhm";

I really dont understand whats the deal with that websocket.. is that really so overloaded?
anyways.. I added this to NiceHashStats.cs

    public static void SetAlgorithmRates(JArray data = null)
    {
        if (data != null)
            File.WriteAllText("LastNiceHashSma.json", data.ToString());
        else
        {
            try
            {
                var serializedJson = File.ReadAllText("LastNiceHashSma.json");
                data = JArray.Parse(serializedJson);
                niceHashData = new NiceHashData();
            }
            catch
            {
                return;
            }
        }

and

        if (Globals.NiceHashData == null)
            NiceHashStats.SetAlgorithmRates();

to StartMining();

that way, even if I dont get the latest profitability data, I am still able to mine on account of the last stats. when the program restarts.

everything is working. Only the algorithm is not the same. The first problem is that the SMA data does not always have time to come before verification. Another problem is that the program every minute, until it connects, sends up to 20 connection requests. And this is only from one client.

the socket is clearly unstable - it shouldnt stop the program start.
it definitely makes sense to serialize the previous data, and use this, if the miner crashes, and cant connect to the socket again.
its just 5 lines of code, and you never get the "Unable to get NiceHash profitability data" again.

question - do I understand correctly, that the program only check profitability data when it starts up?

it may be necessary to use the old method of obtaining SMA (https://api.nicehash.com/api?method=simplemultialgo.info), until there is a connection to the WebSocket?

I guess HTTPS is more stable than the websocket (wss://api.nicehash.com/v2/nhm)
Probably would make more sense to get the data from there. Its also 10x less code.
The code base requires refactoring, obviously. With Bitcoin rate so high, and Nicehash being so popular, why is it such a mess? :D

I think that the connection code (that downloads the SMA etc) should do everything it can to ensure connectivity, i.e. if a websocket connection can't be established it should intelligently fall back to the HTTPS method, or even used cached data if it isn't too stale. i.e. It should do everything it can to ensure mining isn't unnecessarily halted.

Also, I don't understand why NHML is using "blocking" MessageBoxes to display transient errors.. because these MessageBoxes prevent the application from automatically retrying without user input.

I agree, as I said.. this code base is in dire need of refactoring. I just dont undertand why NiceHash doesnt care. it doesnt look like they are too poor :\

I have the exakt same problem as tonwilware. I even have one computer here at home working, adn the other not.
One of the is currently mining, the other not. I did however for a little while tonight, now it can't connect again.
Whatever the exakt issue is, it's not very good that all miners try to reconnect so many times so close to each other as it is, it creates tremendous load on the server, probably making it ever harder to connect, if this is part of the problem...
Would be very appreciated if any dev would take a look at this.

added an alternate way to get sma. add Pull request #625

I think there are two issues described here

What @tonsilware reports is a legitimate fix, thank you I will work on it for the next update. This issue is auto-start profitability breaking when using an older version. This likely doesn't affect everyone and there is no actual connection problem - just the invoke call causes the auto-mining to start before the SMA info is received. Everything else should work correctly, just the mining doesn't auto-start

Second, the more widespread issue of the socket connection that I made an overarching issue for #707

The bug is still here, 3 months later. Old version problem and including minor version updates. This is very, very annoying still

The problem is that the messages block the work of the main thread.

It seems to be explicitly fixed in the last update, that is; from what I see when I start the computers

Issue related to old nhm version/build. Please use latest version and open a new issue for bugs and/or features.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

navjack picture navjack  路  3Comments

korisame picture korisame  路  4Comments

mandeep148 picture mandeep148  路  3Comments

Avalonis picture Avalonis  路  4Comments

AlexandreMarkus picture AlexandreMarkus  路  3Comments