Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.

0.18.0 API not working? #1918

Closed
UselessGuru opened this issue Aug 9, 2019 · 3 comments
Closed

0.18.0 API not working? #1918

UselessGuru opened this issue Aug 9, 2019 · 3 comments

Comments

@UselessGuru
Copy link

UselessGuru commented Aug 9, 2019

ethminer.exe --api-bind 127.0.0.1:4000 --pool stratum+tcp://***********%2e*************:x@us-east.ethash-hub.miningpoolhub.com:17020 --cuda --cuda-devices 0

--> API not responding. 0.17.1 is working fine

Powershell code to reproduce:
(taken from https://github.com/MultiPoolMiner/MultiPoolMiner/blob/master/APIs/Claymore.ps1)

        $Server = "localhost"
        $Timeout = 5 #seconds

        $Request = @{id = 1; jsonrpc = "2.0"; method = "miner_getstat1"} | ConvertTo-Json -Compress
        $Response = ""

        try {
            $Response = Invoke-TcpRequest $Server 4000 $Request $Timeout -ErrorAction Stop
            $Data = $Response | ConvertFrom-Json -ErrorAction Stop
        }
        catch {
            return @($Request, $Response)
        }

ethminer.exe --api-bind -4000 --pool stratum+tcp://***********%2e*************:x@us-east.ethash-hub.miningpoolhub.com:17020 --cuda --cuda-devices 0

ethminer 0.18.0
Build: windows/release/msvc

Error: --api-bind: Invalid syntax

@AndreaLanfranchi
Copy link
Collaborator

AndreaLanfranchi commented Aug 12, 2019

Two problems here.
As far as I know Invoke-TcpRequest is not a PowerShell 3.0 cmdlet. Probably you're missing the include which is set at the top of the script you have copied from.

This is a powershell script from me which is tested working with 0.18

$ServerAddress = "192.168.10.2"
$ServerPort = 3333

$Request = @{id = 1; jsonrpc = "2.0"; method = "miner_getstat1"} | ConvertTo-Json -Compress
$Response = ""

$tcpConnection = New-Object System.Net.Sockets.TcpClient($ServerAddress, $ServerPort)
$tcpStream = $tcpConnection.GetStream()
$reader = New-Object System.IO.StreamReader($tcpStream)
$writer = New-Object System.IO.StreamWriter($tcpStream)
$writer.AutoFlush = $true

while ($tcpConnection.Connected)
{

    $writer.WriteLine($Request) | Out-Null

    while ($tcpStream.DataAvailable)
    {
        $reader.ReadLine() | convertfrom-json | convertto-json -depth 100
    }

    if ($tcpConnection.Connected)
    {

        Write-Host -NoNewline "Press ENTER to refresh data or type 'quit' + ENTER to exit> "    
        $command = Read-Host

        if ($command -eq "quit")
        {
            break
        }
    }
}

$reader.Close()
$writer.Close()
$tcpConnection.Close()

Adjust your values for server and port and run the script.

The second problem related to invalid syntax is due to the fact you enter --api-bind -4000 but that is wrong. --api-bind requires a value in the form address[:port]. So either you enter --api-bind 127.0.0.1:-4000 or you enter --api-bind 127.0.0.1 --api-port -4000

@AndreaLanfranchi
Copy link
Collaborator

No feed back.
Closing

@UselessGuru
Copy link
Author

UselessGuru commented Sep 22, 2019

No feed back.
Closing

I was away... called holidays :-)

ethminer.exe --api-bind 127.0.0.1 --api-port -4001 --pool stratum+tcp://***********%2e*************:x@us-east.ethash-hub.miningpoolhub.com:17020 --cuda --cuda-devices 0

generates a syntax error message 👎

ethminer.exe --api-bind 127.0.0.1:-4001 --pool stratum+tcp://***********%2e*************:x@us-east.ethash-hub.miningpoolhub.com:17020 --cuda --cuda-devices 0

gets the miner started, but then stalls (both AMD & NVIDIA):
cl 22:57:21 cl-0 3.23 GB of DAG data generated in 7
or
cu 22:57:26 cuda-0 Generated DAG + Light in 14

This is with the latest NVIDIA 436.30 or AMD 19.9.2 drivers.

As far as I know Invoke-TcpRequest is not a PowerShell 3.0 cmdlet.

True, but MultiPoolMiner has a function which works perfectly with 0.17.1:

function Invoke-TcpRequest { 
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [String]$Server = "localhost", 
        [Parameter(Mandatory = $true)]
        [String]$Port, 
        [Parameter(Mandatory = $true)]
        [String]$Request, 
        [Parameter(Mandatory = $true)]
        [Int]$Timeout = 10, #seconds
        [Parameter(Mandatory = $false)]
        [Bool]$ReadToEnd = $false
    )

    try { 
        $Client = New-Object System.Net.Sockets.TcpClient $Server, $Port
        $Stream = $Client.GetStream()
        $Writer = New-Object System.IO.StreamWriter $Stream
        $Reader = New-Object System.IO.StreamReader $Stream
        $Client.SendTimeout = $Timeout * 1000
        $Client.ReceiveTimeout = $Timeout * 1000
        $Writer.AutoFlush = $true

        $Writer.WriteLine($Request)
        if ($ReadToEnd) { $Response = $Reader.ReadToEnd() } else { $Response = $Reader.ReadLine() }
    }
    finally { 
        if ($Reader) { $Reader.Close(); $Reader.Dispose() }
        if ($Writer) { $Writer.Close(); $Writer.Dispose() }
        if ($Stream) { $Stream.Close(); $Stream.Dispose() }
        if ($Client) { $Client.Close(); $Client.Dispose() }
    }

    $Response
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants