Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPI disconnects #58

Open
ebolisa opened this issue Sep 23, 2021 · 8 comments
Open

RPI disconnects #58

ebolisa opened this issue Sep 23, 2021 · 8 comments

Comments

@ebolisa
Copy link

ebolisa commented Sep 23, 2021

Raspberry pi (any) with ethernet connection.

The code works fine for few minutes then disconnects with no errors.
Tried to set up line 'blynk = BlynkLib.Blynk(BLYNK_AUTH)' to 'blynk = BlynkLib.Blynk(BLYNK_AUTH, insecure= True)' but I get error: AttributeError: 'socket' object has no attribute 'write'

The option 'insecure=True' works fine on ESP32s however.

Any ideas?
TIA

@Judas2016
Copy link

I am having the same problem on MacOS.
./manual_tests/test_blynkV2.py::BlynkPublisherTest::test_pushvalue Failed with Error: 'socket' object has no attribute 'write'
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 59, in testPartExecutor
yield
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 615, in run
testMethod()
File "/Users/jeff/GitHub/wiab/tests/manual_tests/test_blynkV2.py", line 28, in test_pushvalue
blynk = BlynkLib.Blynk(BLYNK_AUTH_TOKEN, insecure=True)
File "/Users/jeff/GitHub/wiab/.env/lib/python3.7/site-packages/BlynkLib.py", line 214, in init
BlynkProtocol.init(self, auth, **kwargs)
File "/Users/jeff/GitHub/wiab/.env/lib/python3.7/site-packages/BlynkLib.py", line 81, in init
self.connect()
File "/Users/jeff/GitHub/wiab/.env/lib/python3.7/site-packages/BlynkLib.py", line 245, in connect
BlynkProtocol.connect(self)
File "/Users/jeff/GitHub/wiab/.env/lib/python3.7/site-packages/BlynkLib.py", line 125, in connect
self._send(MSG_HW_LOGIN, self.auth)
File "/Users/jeff/GitHub/wiab/.env/lib/python3.7/site-packages/BlynkLib.py", line 117, in _send
self._write(msg)
File "/Users/jeff/GitHub/wiab/.env/lib/python3.7/site-packages/BlynkLib.py", line 249, in _write
self.conn.write(data)
AttributeError: 'socket' object has no attribute 'write'

@ebolisa
Copy link
Author

ebolisa commented Oct 14, 2021

@Judas2016 It's not OS related but library. It appears to be a timing problem between the client and server.

@Judas2016
Copy link

Did you have any luck in getting it to work with SSL?

@ebolisa
Copy link
Author

ebolisa commented Oct 14, 2021

Only with ESP not with Raspberry

@Judas2016
Copy link

I got SSL working on macOS and the library works as expected now. I updated the version of Python to latest 3.9 from 3.7 and solved the problem.

@jonathongardner
Copy link

Im noticing the same issue with my RPI disconnecting.

It looks like when the socket tries to read here (and there's no data) you get a timeout so this line doesn't get called for a while. Then when it eventually does get called depending on how long its been these lines get called and it disconnects.

Not sure if this is a bug in the code or if the conn.read is expecting the blynk server to send data/heartbeat. I honestly just removed those two lines (136-137) and my RPI stoped disconnecting and the project has been working.

If this is a bug in the code than I'm sure there is a more elegant way to fix this

@ebolisa
Copy link
Author

ebolisa commented Jan 25, 2022

@jonathongardner Interesting! Which server are you using? The central or the assigned one? In my case, the connection works better with the assigned one being it lon1 or fran1.

@jonathongardner
Copy link

Yeah I'm just using the default one in the package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants