node-stratum icon indicating copy to clipboard operation
node-stratum copied to clipboard

Connecting to a remote stratum server

Open aashidham opened this issue 7 years ago • 14 comments

I've used the client.js inside the example directory and tried to connect to a remote stratum server: https://gist.github.com/aashidham/dd33b949d8ad4eb9ba57301b7888065e

But it fails with 'connection closed'. Any idea why?

aashidham avatar Oct 26 '16 02:10 aashidham

that code is for demonstration only, it sends fake data when connecting, that's why it's disconnecting you right way

pocesar avatar Oct 26 '16 16:10 pocesar

It disconnects even before authorizatjon, even before it sends fake data.

On Oct 26, 2016, at 9:32 AM, Paulo Cesar [email protected] wrote:

that code is for demonstration only, it sends fake data when connecting, that's why it's disconnecting you right way

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

aashidham avatar Oct 26 '16 16:10 aashidham

before executing the client, set the environment variable set DEBUG=stratum,jsonrpc in your command line (export if you in linux), you'll see what's happening underneath

pocesar avatar Oct 26 '16 17:10 pocesar

I am having exactly the same issue right now. For multiple remote popular pools which supports stratum protocol, i am getting "Connection closed" right after trying to connect to the pool.

mersed avatar Oct 10 '17 15:10 mersed

I am having the same issue as well.

masajid390 avatar Oct 12 '17 11:10 masajid390

@mersed @aashidham did you get some other way to connect?

masajid390 avatar Oct 15 '17 12:10 masajid390

Added https://github.com/envman/node-stratum/commit/84605482d433072aa989082be8cb6160e0c6310d to send the error out.

then the following error code shows the socket error:

client.on('error', function(socket, e) {
  socket.destroy();
  console.log('Connection closed', e);
  process.exit(1);
});

mine was ENOTFOUND, removed the stratum+tcp:// from the start of the address and it worked.

envman avatar Oct 25 '17 19:10 envman

@envman thanks for that, can you make the PR? I'll merge it (as it's not a breaking change)

pocesar avatar Oct 25 '17 22:10 pocesar

@pocesar opened: https://github.com/pocesar/node-stratum/pull/16

Not sure if it's worth adding some checks to make sure the URL is correct, could auto remove stratum+tcp:// maybe?

envman avatar Oct 25 '17 23:10 envman

maybe that could be added to the README, because, indeed, stratum+tcp is not a valid protocol per se

pocesar avatar Oct 25 '17 23:10 pocesar

@pocesar Thanks :-)

masajid390 avatar Oct 26 '17 04:10 masajid390

added to readme, just check you're happy with the way I wrote it ;)

envman avatar Oct 26 '17 06:10 envman

@marslan390 Are you able to use the client in order to connect with the remote server? Indeed, removing "stratum+tcp" will allow you to connect to the server, but I am still encountering few issues.

After the connection, I am sending the subscribe and I am getting appropriate response to that call. After that, sending authorize, but response is not what I am expecting to be:

With socket.stratumAuthorize(stratumUsername, stratumPassword) we are sending: {"params": ["slush.miner1", "password"], "id": 2, "method": "mining.authorize"}\n And we are expecting: {"error": null, "id": 2, "result": true}\n

but that actually is not what happens. In this case on "socket.stratumAuthorize()" im getting the same response from the server as on socket.stratumSubscribe() .

Tested against https://www.litecoinpool.org and few other servers/pools.

Also please make a note that using raw socket connection (nodejs net module) within the node and writting to the socket directly using the same parameters will result with proper messages.

mersed avatar Oct 30 '17 03:10 mersed

@mersed did you got it working?

joepvandepol avatar Oct 18 '20 14:10 joepvandepol