ethminer version 0.13.0 API leaves connections in CLOSE_WAIT state

Created on 5 Mar 2018  路  18Comments  路  Source: ethereum-mining/ethminer

ethminer version 0.13.0 API leaves connections in CLOSE_WAIT state after it has been interrogated by external app, witch results in overload and API not able to respond to new requests.

tcp 0 0 192.168.122.68:4000 192.168.120.91:43872 CLOSE_WAIT 1000 140109385 26898/ethminer
tcp 0 0 192.168.122.68:4000 192.168.120.91:43870 CLOSE_WAIT 1000 140109383 26898/ethminer
tcp 0 0 192.168.122.68:4000 192.168.120.61:44760 CLOSE_WAIT 1000 139952752 26898/ethminer
tcp 0 0 192.168.122.68:4000 192.168.120.61:59488 CLOSE_WAIT 1000 140286591 26898/ethminer
tcp 0 0 192.168.122.68:4000 192.168.120.61:58770 CLOSE_WAIT 1000 140272773 26898/ethminer

bug invalid

All 18 comments

does the external app closes the connection or wait for the server to close?
As far as i know you are right and the library we use for the jsonrpc server does not close the connection after sending the result.

Would it be possible to fix the issue for 0.14 ?

@smurfy do you think possible for you to change the code and have the api close the connection after the response.
It might be quick to fix.
It is creating havoc, with my reporting rig, I m unable to use the ethermine api because is gives a timeout error when I m querying for the results. I keep getting Socket error: timed out
I m a SQL server guy, switching to linux, mysql, bash, awk , lol so many, but I don t think I can get to undestand to C, lol...

I can't tell if it's the exact same issue, but my python mining script uses a socket to poll the API, and while it works fine with claymore, it is timing out ethminer.

I have tried the precompiled 0.13.0 release.

I also compiled from master, commit 0c65908, and experience the same problem.

Hoping this gets fixed, thanks!

Same behavior on 0.12.0 release, _but_ -- I managed to get it working in my script.

Testing with netcat and both claymore and ethminer, I found that sending the json string, and then an additional Enter, would end the session.

For whatever reason, in my python code to get the data from claymore, it just works to send only the json string and then read the data -- claymore ends the session and the python socket receives the data.

With ethminer, the same code doesn't work -- ethminer leaves the connection open and the python socket hangs -- _but_ if after sending the json string I send an additional b"\n" then ethminer closes the connection, the python socket reads the data, and all is well.

@apiontek could you explain how to send the additional "\n" ?
I m using this
echo '{"id":0,"jsonrpc":"2.0","method":"miner_getstathr"}' | netcat gaming106.lan 3333

echo "{\"id\":0,\"jsonrpc\":\"2.0\",\"method\":\"miner_getstathr\"}\n" | netcat gaming106.lan 3333

no it still hangs, so lets start learning python...

First, this doesn't work and I think I know why, but it _should_ be:

echo -e '{"id":0,"jsonrpc":"2.0","method":"miner_getstathr"}\n' | netcat gaming106.lan 3333

The -e makes echo parse the \n and send it as a new line character. But it doesn't work because you're sending it immediately before ethminer has a chance to respond, so it's not the same as an interactive netcat session, where one sends the {...} json, gets a response from ethminer, and then sends a \n by pressing the Enter key.

I could be wrong!

I also tried putting the {...} command into a text file, along with a few newlines, and then doing:

cat cmdtest.txt | netcat gaming106.lan 3333

And even

netcat gaming106.lan 3333 < cmdtest.txt

But none of it worked. I think some scripting beyond bash is definitely in order.

On that note, the following python code works for me. I've written this so it can run on its own with two arguments, like python3 script.py <host> <port> so if you already have bash scripts you could incorporate its output.

import sys, socket

def get_rpc_response(host: str, port: int):
    rpc_cmd = '{"id": 0, "jsonrpc": "2.0", "method": "miner_getstat1"}\n'
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((host, port))
    s.sendall(str.encode(rpc_cmd))
    data = s.recv(4096)
    print(str(data, 'utf-8'))

if __name__ == '__main__':
    if len(sys.argv) < 3:
        print("Please provide two arguments:")
        print("    " + sys.argv[0] + " <host> <port>")
    else:
        host = sys.argv[1]
        port = int(sys.argv[2])
        get_rpc_response(host, port)

@apiontek you are right, it doesn't.
Thank you a lot for your suggestion, I think it will work for me.

Not sure about python but a '\n' is different than "\n" in ruby. Could be an issue for you. Regardless I am having a similar issue. Netcat command works fine and my ruby script from #1081 works just fine in Claymore and a few other miners, but ethminer api is different. From what I can tell the ethminer api doesn't close the connection. So the client appears to have to work around the issue when the server should be doing the work. Also this was tested on 0.14.0.dev2

Correct netcat command echo '{"id":0,"jsonrpc":"2.0","method":"miner_getstat1"}' | nc localhost 3333

Amended by #1201 #1227

i received this data, can please you tell me meaning of each field?

{"id": 0, "error": null, "result": ["10.5 - ETH", "1101", "169431;2970;0", "19432;30009;30043;30035;29953;29957", "0;0;0", "off;off;off;off;off;off", "64;46;66;43;67;46;67;46;64;63;61;56", "asia1.ethermine.org:14444", "0;0;0;0"]}

thank

@namnguyendsn this an output from claymore.
We're ethminer here.
If you want to learn our API outputs please refer to this document.

https://github.com/ethereum-mining/ethminer/blob/master/docs/API_DOCUMENTATION.md

thank for reply
but, what different between miner_getstat1 and miner_getstathr?

claymore v10.5 doesnot support miner_getstathr right?

but, what different between miner_getstat1 and miner_getstathr?

I think reading the documentation you can spot differences immediately. Data is _almost_the same: but representation is single arrays for each member. Plus it also reports whether or not a single gpu is paused.

claymore v10.5 doesnot support miner_getstathr right?

Do not know but it's not our business.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bartocc picture bartocc  路  3Comments

RJBetancor picture RJBetancor  路  5Comments

skynet picture skynet  路  4Comments

krrkrr picture krrkrr  路  5Comments

MaynardMiner picture MaynardMiner  路  5Comments