Socket error: [Errno 111] Connection refused


#1

Hi Smart People!!

I have an issue I can’t seem to determine the solution. First, the code:

self.credentials = {'devicekey': config.vars['devicekey']}
globalVars.hologram = HologramCloud(self.credentials, network='cellular')

result = globalVars.hologram.network.connect()
if result == False:
    print 'Failed to connect to cell network'

location = globalVars.hologram.network.location
#check if the monitor is requesting a location update
time.sleep(0.5)
globalVars.hologram.openReceiveSocket()
time.sleep(20)
globalVars.hologram.closeReceiveSocket()
recv = globalVars.hologram.popReceivedMessage()
print recv

What I’m trying to do is return the location of the device, then check if there are any pending Cloud Data messages. I can get it to receive messages only if I don’t check the location prior to receiving.

The Hologram Dashboard always returns an error, and is always one of the two:

  • Socket error: [Errno 111] Connection refused
  • Socket error: timed out

Any ideas? Thanks!


#2

Furthermore, I also tried an event subscription. I can get the subscription to work also, for as long as I don’t try to access network.location:

globalVars.hologram.event.subscribe('message.received', self.messageReceived)
result = globalVars.hologram.network.connect()
# location = globalVars.hologram.network.location #doesn't work
globalVars.hologram.openReceiveSocket()
def messageReceived(self):
      print "hello! I received something!"
      recv = globalVars.hologram.popReceivedMessage()
      print recv