Author

Topic: [poclbm] Wanna get rid of your "Problems Communicating With Bitcoin RPC"? (Read 2892 times)

full member
Activity: 140
Merit: 100
hmm. also experiencing this problem.
I've made another patch here: http://forum.bitcoin.org/index.php?topic=24990.0
newbie
Activity: 19
Merit: 0
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.
newbie
Activity: 16
Merit: 0
I'm using GUIminer in windows 7 myself..

Any solution? Please have a look at my thread..
sr. member
Activity: 337
Merit: 250
I think a lot of people have no idea how to do this.  I have looked for that file, but I cannot find it.
newbie
Activity: 24
Merit: 0
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:
Jump to: