socket.error: [Errno 146] Connection refused

Dear Everyone,

I have the following sketch running in my Yun:

#include <Bridge.h>

char chrLikeCount[6];
char chrLastCount[6];

void setup() {
  Bridge.begin();
  
  Bridge.put("fbhandle","Mashable");
  delay(1000);
  
}

void loop() {
  int likeCount = 0;
  likeCount = Bridge.get("likecount", chrLikeCount, 6);
  delay(10000);
}

And on the python side I have:

import facebook
import sys
import time
sys.path.insert(0, '/usr/lib/python2.7/bridge/')
from bridgeclient import BridgeClient as bridgeclient
bridgecli = bridgeclient()
graph = facebook.GraphAPI()
fbhandle = ""
print "Getting handle..."
while fbhandle == "":
  fbhandle = bridgecli.get('fbhandle')
  print "got handle %s" % fbhandle
  time.sleep(5)
  break

while 1 == 1:
  likecount = graph.get_object('/'+fbhandle)['likes']
  print "%s has %s fans" % (fbhandle, graph.get_object('/'+fbhandle)['likes'])
  if likecount:
    bridgecli.put('likecount', likecount)
    print "%s crossed the bridge towards %s" % (graph.get_object('/'+fbhandle)['likes'], fbhandle)

So, I upload the sketch, give it some time, then I start (via ssh console) the python script on linino, and this is what I get:

root@donatoyun:/mnt/sda1/arduino/donato/fblikecounter# python getlikes.py
Getting handle...
got handle Mashable
Mashable has 2983229 fans
2983229 crossed the bridge towards Mashable
Mashable has 2983229 fans
2983229 crossed the bridge towards Mashable
Mashable has 2983230 fans
2983230 crossed the bridge towards Mashable
Mashable has 2983230 fans
2983230 crossed the bridge towards Mashable
Mashable has 2983230 fans
Traceback (most recent call last):
  File "getlikes.py", line 20, in <module>
    bridgecli.put('likecount', likecount)
  File "/usr/lib/python2.7/bridge/bridgeclient.py", line 92, in put
    json = self.socket_open()
  File "/usr/lib/python2.7/bridge/bridgeclient.py", line 59, in socket_open
    self.json = TCPJSONClient('127.0.0.1', 5700)
  File "/usr/lib/python2.7/bridge/tcp.py", line 65, in __init__
    TCPClient.__init__(self, address, port)
  File "/usr/lib/python2.7/bridge/tcp.py", line 38, in __init__
    client.connect((address, port))
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 146] Connection refused

Which seems that when the

likeCount = Bridge.get("likecount", chrLikeCount, 6);

line is run, the socket connection drops...

Anyone knows how to solve/correct this?

Best regards,

Maybe you are making too many requests to the server and it closes down the connection. Try to slow down the requests and see if it works.