cazala / coin-hive-stratum

use CoinHive's JavaScript miner on any stratum pool
http://npmjs.com/package/coin-hive-stratum
416 stars 461 forks source link

Catching errors and reconnecting #4

Closed slayerulan closed 7 years ago

slayerulan commented 7 years ago

Hello, Thanks for your work.

Actions like below causes the application to terminate cause they're not catched:

And it doesnt reconnect to pool if there is some socket error happened

mouradski commented 7 years ago

Thanx cazala for your work :)

/usr/lib/node_modules/coin-hive-stratum/node_modules/ws/lib/WebSocket.js:355 else throw new Error('not opened'); ^

Error: not opened at WebSocket.send (/usr/lib/node_modules/coin-hive-stratum/node_modules/ws/lib/WebSocket.js:355:18) at sendToMiner (/usr/lib/node_modules/coin-hive-stratum/src/proxy.js:105:19) at Socket. (/usr/lib/node_modules/coin-hive-stratum/src/proxy.js:151:11) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:547:20)

cazala commented 7 years ago

Which version are you using? is it v1.0.2 ?

slayerulan commented 7 years ago

@cazala i am using v1.0.2

fogoat commented 7 years ago

What happens if proxy loses connection with pool? Does proxy reconnect? Can I wrap the program around a script that will restart stratum proxy? What happens when miner is hashing but proxy is down? Does that mean hashes are wasted? If proxy restarts will miner eventually reconnect and submit hashes?

It'd be nice to have a HTML page that has more UI so all these details are shown on the web page. I'm using the miner UI from coinhive which is helpful... but it doesn't show accepted hashes.

I don't know of any pools that reward by hashes submitted... usually it by share difficulty and actual block has to be solved.

cazala commented 7 years ago

@sunk818 if the connection to the pool is lost, the ws connection is closed. The miner then tries to reconnect, this creates a new ws connection with it's own tcp connection and everything goes well after that. If the ws connection to the miner is lost, the server destroys that particular connection's tcp socket gracefully and everything goes well. You should run this proxy with forever or a similiar tool to restart it if it dies for some reason tho.

fogoat commented 7 years ago

Well Im not concerned with proxy crashing (exiting), more that it is running but in a zombie state. How would one test for this?

cazala commented 7 years ago

It won't keep running in a 'zombie' state, it will just exit. I need to catch those exceptions so it doesn't die, but for now you can run it with forever or other watchdog and it should work fine.

korzhyk commented 7 years ago

Some work seems to be done! https://github.com/cazala/coin-hive-stratum/pull/16

cazala commented 7 years ago

released under v1.1.2, thanks @korzhyk !