Bitcoin Forum
May 14, 2024, 06:36:32 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [poclbm] Wanna get rid of your "Problems Communicating With Bitcoin RPC"?  (Read 2887 times)
derjanb (OP)
Newbie
*
Offline Offline

Activity: 24
Merit: 0


View Profile
June 29, 2011, 08:12:51 AM
 #1

I'm using poclbm with Ubuntu 11.04 and somehow there were a lot of "Problems Communicating With Bitcoin RPC" messages. After some seconds of retrying new work was retrieved and my HD 6870 restarted working. This is ugly and produces a lot of idle time.

So I've reviewed the python code and noticed that poclbm was trying to get new work only once, then showing the error message, leaving the function and retries to get work later.
This is not really a problem, but if a solved block is passed the function, it behaves exactly the same. Shocked This means, you've worked a lot of days to solve a block and then one network error is enough to move your 50 BTC afar?! So I changed this to retry a connection a settable number of times.

Additionally I've modified the work prefetch magic to avoid idle time on slow and/or high latency internet lines, because for me poclbm was working 30 seconds, idling 10-20 seconds, working 30 seconds...  Undecided

If you want to try it you can find the reworked version here: http://pastebin.com/dNHuEFma

Maybe you can post some issues if there are any or just report success. Grin

I'm still a newbie, so I'm posting here. Roll Eyes If you can, please move my post if it does not belong to this section.

This is the patch I've made to BitcoinMiner.py:

Code:
--- BitcoinMiner.py     2011-06-24 12:54:19.000000000 +0200
+++ BitcoinMinerDJ.py   2011-06-29 09:55:54.000000000 +0200
@@ -26,13 +26,15 @@
 socket.socket = socketwrap
 
 
-VERSION = '2011.beta4'
+VERSION = '2011.beta4.derjanb.v1'
 
 USER_AGENT = 'poclbm/' + VERSION
 
 TIME_FORMAT = '%d/%m/%Y %H:%M:%S'
 
-TIMEOUT = 5
+TIMEOUT = 10
+
+RETRIES = 3
 
 LONG_POLL_TIMEOUT = 3600
 
@@ -122,6 +124,7 @@
                self.failback_getwork_count = 0
                self.failback_attempt_count = 0
                self.pool = None
+               self.currentrate = 0
 
                host = '%s:%s' % (host.replace('http://', ''), port)
                self.primary = (user, password, host)
@@ -140,6 +143,7 @@
                                except ValueError:
                                        self.sayLine('Ignored invalid backup pool: %s', pool)
                                        continue
+               self.sayLine(' running %s', USER_AGENT)
 
        def say(self, format, args=()):
                with self.outputLock:
@@ -160,6 +164,7 @@
                self.stop = True
 
        def hashrate(self, rate):
+               self.currentrate = (self.currentrate + rate) / 2
                self.say('%s khash/s', rate)
 
        def failure(self, message):
@@ -224,49 +229,70 @@
                                                if accepted != None:
                                                        self.blockFound(pack('I', long(h[6])).encode('hex'), accepted)
 
+       def getAscii(self, n):
+               cnt = n % 4
+               if cnt == 0:
+                       return '|'
+               if cnt == 1:
+                       return '/'
+               if cnt == 2:
+                       return '-'
+               if cnt == 3:
+                       return '\\'
+               return ' '
+
        def getwork(self, data=None):
-               save_pool = None
-               try:
-                       if self.pool != self.primary and self.failback > 0:
-                               if self.failback_getwork_count >= self.failback:
-                                       save_pool = self.pool
-                                       self.setpool(self.primary)
-                                       self.connection = None
-                                       self.sayLine("Attempting to fail back to primary pool")
-                               self.failback_getwork_count += 1
-                       if not self.connection:
-                               self.connection = httplib.HTTPConnection(self.host, strict=True, timeout=TIMEOUT)
-                       self.postdata['params'] = if_else(data, [data], [])
-                       (self.connection, result) = self.request(self.connection, '/', self.headers, dumps(self.postdata))
-                       self.errors = 0
-                       if self.pool == self.primary:
-                               self.backup_pool_index = 0
-                               self.failback_getwork_count = 0
-                               self.failback_attempt_count = 0
-                       return result['result']
-               except NotAuthorized:
-                       self.failure('Wrong username or password')
-               except RPCError as e:
-                       self.say('%s', e)
-               except (IOError, httplib.HTTPException, ValueError):
-                       if save_pool:
-                               self.failback_attempt_count += 1
-                               self.setpool(save_pool)
-                               self.sayLine('Still unable to reconnect to primary pool (attempt %s), failing over', self.failback_attempt_count)
-                               self.failback_getwork_count = 0
-                               return
-                       self.say('Problems communicating with bitcoin RPC %s %s', (self.errors, self.tolerance))
-                       self.errors += 1
-                       if self.errors > self.tolerance+1:
+               max = if_else(data, 2*RETRIES, RETRIES)
+               for n in range(1, max):
+                       save_pool = None
+                       try:
+                               if self.pool != self.primary and self.failback > 0:
+                                       if self.failback_getwork_count >= self.failback:
+                                               save_pool = self.pool
+                                               self.setpool(self.primary)
+                                               self.connection = None
+                                               self.sayLine("Attempting to fail back to primary pool")
+                                       self.failback_getwork_count += 1
+                               if not self.connection:
+                                       self.connection = httplib.HTTPConnection(self.host, strict=True, timeout=TIMEOUT)
+                               self.postdata['params'] = if_else(data, [data], [])
+                               (self.connection, result) = self.request(self.connection, '/', self.headers, dumps(self.postdata))
                                self.errors = 0
-                               if self.backup_pool_index >= len(self.backup):
-                                       self.sayLine("No more backup pools left. Using primary and starting over.")
-                                       pool = self.primary
+                               if self.pool == self.primary:
                                        self.backup_pool_index = 0
-                               else:
-                                       pool = self.backup[self.backup_pool_index]
-                                       self.backup_pool_index += 1
-                               self.setpool(pool)
+                                       self.failback_getwork_count = 0
+                                       self.failback_attempt_count = 0
+                               return result['result']
+                       except NotAuthorized:
+                               self.failure('Wrong username or password')
+                               return
+                       except RPCError as e:
+                               self.say('%s', e)
+                       except (IOError, httplib.HTTPException, ValueError):
+                               if save_pool:
+                                       self.failback_attempt_count += 1
+                                       self.setpool(save_pool)
+                                       self.sayLine('Still unable to reconnect to primary pool (attempt %s), failing over', self.failback_attempt_count)
+                                       self.failback_getwork_count = 0
+                                       return
+                               if n == max:
+                                       self.say('Problems communicating with bitcoin RPC %s %s', (self.errors, self.tolerance))
+                                       self.errors += 1
+                               if self.errors > self.tolerance+1:
+                                       self.errors = 0
+                                       if self.backup_pool_index >= len(self.backup):
+                                               self.sayLine("No more backup pools left. Using primary and starting over.")
+                                               pool = self.primary
+                                               self.backup_pool_index = 0
+                                       else:
+                                               pool = self.backup[self.backup_pool_index]
+                                               self.backup_pool_index += 1
+                                       self.setpool(pool)
+               if (self.connection):
+                       self.connection.close()
+                       self.connection = None
+               self.say('Please wait: %s', self.getAscii(n))
+               sleep(0.50)
 
        def setpool(self, pool):
                self.pool = pool
@@ -408,7 +434,7 @@
                                cl.enqueue_write_buffer(queue, output_buf, output)
 
                        if self.updateTime == '':
-                               if noncesLeft < (TIMEOUT+1) * globalThreads * self.frames:
+                               if noncesLeft < (TIMEOUT+1) * self.currentrate * 1000:
                                        self.update = True
                                        noncesLeft += 0xFFFFFFFFFFFF
                                elif 0xFFFFFFFFFFF < noncesLeft < 0xFFFFFFFFFFFF:
1715668592
Hero Member
*
Offline Offline

Posts: 1715668592

View Profile Personal Message (Offline)

Ignore
1715668592
Reply with quote  #2

1715668592
Report to moderator
1715668592
Hero Member
*
Offline Offline

Posts: 1715668592

View Profile Personal Message (Offline)

Ignore
1715668592
Reply with quote  #2

1715668592
Report to moderator
Even if you use Bitcoin through Tor, the way transactions are handled by the network makes anonymity difficult to achieve. Do not expect your transactions to be anonymous unless you really know what you're doing.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715668592
Hero Member
*
Offline Offline

Posts: 1715668592

View Profile Personal Message (Offline)

Ignore
1715668592
Reply with quote  #2

1715668592
Report to moderator
1715668592
Hero Member
*
Offline Offline

Posts: 1715668592

View Profile Personal Message (Offline)

Ignore
1715668592
Reply with quote  #2

1715668592
Report to moderator
QuantumQrack
Sr. Member
****
Offline Offline

Activity: 337
Merit: 250


View Profile
June 29, 2011, 10:31:41 PM
 #2

I think a lot of people have no idea how to do this.  I have looked for that file, but I cannot find it.
skillerd
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
June 29, 2011, 10:40:50 PM
 #3

I'm using GUIminer in windows 7 myself..

Any solution? Please have a look at my thread..
quantium
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
July 01, 2011, 12:14:35 PM
 #4

It seems to me as someone new to all of this that what would be most helpful would be if the software was able to define more closely what the communication problem is. I have got both a Ubuntu machine and an XP64 machine giving this "Problems Communicating With Bitcoin RPC" message and have been able to get neither to work. Bitcoin itself loads blocks and makes connections. The problem seems to be communication between guiminer, or phoenix and bitcoin.
techwtf
Full Member
***
Offline Offline

Activity: 140
Merit: 100


View Profile
July 01, 2011, 02:26:54 PM
 #5

hmm. also experiencing this problem.
I've made another patch here: http://forum.bitcoin.org/index.php?topic=24990.0
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!