Black Lives Matter. Please consider donating to Campaign Zero's mission of ending police violence in America.

Socket.gaierror: [Errno -2] Name or service not known - SOLVED

I’m sending streaming data to Plotly using the Python API running on a Raspberry Pi 2, under Raspbian Wheezy. I’m sending 5 traces within 1 plot, at 1-minute intervals.

All runs happily for several minutes, then the Python script crashes (this is repeatable) with the following error message:

socket.gaierror: [Errno -2] Name or service not known

at the following line in my script:

s1.write(dict(x=x, y=y1))

I guess this is a Python / RPi issue, but any clues?



Solved this! This was part of an unfriendly Python message - I had a 60-second sleep command in my main Python loop, and obviously the delay was greater than 60 seconds on some iterations, so I was getting disconnected from Plotly.

I’ve now reduced the sleep to 30 seconds, and all now seems to be well!