Comments (3)
2020-11-11 21:50:18.349101Z: [DBUG] Broadcasting message to 5
2020-11-11 21:50:18.349346Z: [INFO] Client 5 has disconnected
File "bin/hsapid", line 7, in <module>
main()
File "/Users/david/projects/homeswitch-api/homeswitch/api.py", line 127, in main
api.run()
File "/Users/david/projects/homeswitch-api/homeswitch/api.py", line 110, in run
asyncorepp.loop()
File "/Users/david/projects/homeswitch-api/homeswitch/asyncorepp.py", line 22, in loop
poll_fun(timeout, map)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 156, in poll
read(obj)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 83, in read
obj.handle_read_event()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 449, in handle_read_event
self.handle_read()
File "/Users/david/projects/homeswitch-api/homeswitch/asyncsocket/client.py", line 127, in handle_read
self.emit('read')
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit
remove = [l for l in listeners if not l(*args, **kwargs)]
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__
self.func(*args, **kwargs)
File "/Users/david/projects/homeswitch-api/homeswitch/asyncsocket/client.py", line 86, in _on_read
self.emit('data')
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit
remove = [l for l in listeners if not l(*args, **kwargs)]
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__
self.func(*args, **kwargs)
File "/Users/david/projects/homeswitch-api/homeswitch/hw/tuya.py", line 262, in _on_dev_data
callback(reply)
File "/Users/david/projects/homeswitch-api/homeswitch/hw/tuya.py", line 297, in get_callback
self.emit('status_update', status, origin)
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit
remove = [l for l in listeners if not l(*args, **kwargs)]
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__
self.func(*args, **kwargs)
File "/Users/david/projects/homeswitch-api/homeswitch/device.py", line 45, in _on_status_update
self.emit('status_update', status, origin)
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit
remove = [l for l in listeners if not l(*args, **kwargs)]
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__
self.func(*args, **kwargs)
File "/Users/david/projects/homeswitch-api/homeswitch/api.py", line 30, in <lambda>
dev.on('status_update', lambda status, origin: self._broadcast_status_update(dev_id, status, origin))
File "/Users/david/projects/homeswitch-api/homeswitch/api.py", line 35, in _broadcast_status_update
self.server.broadcast({'devices': {dev_id: {'status': status, 'origin': origin}}})
File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 48, in broadcast
client.message(message)
File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 106, in message
self.send_http(200, body)
File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 123, in send_http
self.send(response)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 550, in send
self.initiate_send()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 537, in initiate_send
num_sent = dispatcher.send(self, self.out_buffer[:512])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 380, in send
self.handle_close()
File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 94, in handle_close
traceback.print_stack()
2020-11-11 21:50:18.355966Z: [INFO] Client 5 has disconnected
File "bin/hsapid", line 7, in <module>
main()
File "/Users/david/projects/homeswitch-api/homeswitch/api.py", line 127, in main
api.run()
File "/Users/david/projects/homeswitch-api/homeswitch/api.py", line 110, in run
asyncorepp.loop()
File "/Users/david/projects/homeswitch-api/homeswitch/asyncorepp.py", line 22, in loop
poll_fun(timeout, map)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 156, in poll
read(obj)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 83, in read
obj.handle_read_event()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 449, in handle_read_event
self.handle_read()
File "/Users/david/projects/homeswitch-api/homeswitch/asyncsocket/client.py", line 127, in handle_read
self.emit('read')
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit
remove = [l for l in listeners if not l(*args, **kwargs)]
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__
self.func(*args, **kwargs)
File "/Users/david/projects/homeswitch-api/homeswitch/asyncsocket/client.py", line 86, in _on_read
self.emit('data')
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit
remove = [l for l in listeners if not l(*args, **kwargs)]
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__
self.func(*args, **kwargs)
File "/Users/david/projects/homeswitch-api/homeswitch/hw/tuya.py", line 262, in _on_dev_data
callback(reply)
File "/Users/david/projects/homeswitch-api/homeswitch/hw/tuya.py", line 297, in get_callback
self.emit('status_update', status, origin)
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit
remove = [l for l in listeners if not l(*args, **kwargs)]
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__
self.func(*args, **kwargs)
File "/Users/david/projects/homeswitch-api/homeswitch/device.py", line 45, in _on_status_update
self.emit('status_update', status, origin)
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit
remove = [l for l in listeners if not l(*args, **kwargs)]
File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__
self.func(*args, **kwargs)
File "/Users/david/projects/homeswitch-api/homeswitch/api.py", line 30, in <lambda>
dev.on('status_update', lambda status, origin: self._broadcast_status_update(dev_id, status, origin))
File "/Users/david/projects/homeswitch-api/homeswitch/api.py", line 35, in _broadcast_status_update
self.server.broadcast({'devices': {dev_id: {'status': status, 'origin': origin}}})
File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 48, in broadcast
client.message(message)
File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 106, in message
self.send_http(200, body)
File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 124, in send_http
self.send(raw_body)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 550, in send
self.initiate_send()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 537, in initiate_send
num_sent = dispatcher.send(self, self.out_buffer[:512])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 380, in send
self.handle_close()
File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 94, in handle_close
traceback.print_stack()
2020-11-11 21:50:18.358171Z: [WARN] Socket (192.168.10.178:6668) error occurred: <type 'exceptions.KeyError'> 5 <traceback object at 0x10af22878>
2020-11-11 21:50:18.359132Z: [ERRO] Socket error on device's bf5d0abdb1e6 connection: ['Traceback (most recent call last):\n', ' File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 83, in read\n obj.handle_read_event()\n', ' File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 449, in handle_read_event\n self.handle_read()\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/asyncsocket/client.py", line 127, in handle_read\n self.emit(\'read\')\n', ' File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit\n remove = [l for l in listeners if not l(*args, **kwargs)]\n', ' File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__\n self.func(*args, **kwargs)\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/asyncsocket/client.py", line 86, in _on_read\n self.emit(\'data\')\n', ' File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit\n remove = [l for l in listeners if not l(*args, **kwargs)]\n', ' File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__\n self.func(*args, **kwargs)\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/hw/tuya.py", line 262, in _on_dev_data\n callback(reply)\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/hw/tuya.py", line 297, in get_callback\n self.emit(\'status_update\', status, origin)\n', ' File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit\n remove = [l for l in listeners if not l(*args, **kwargs)]\n', ' File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__\n self.func(*args, **kwargs)\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/device.py", line 45, in _on_status_update\n self.emit(\'status_update\', status, origin)\n', ' File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 282, in emit\n remove = [l for l in listeners if not l(*args, **kwargs)]\n', ' File "/Users/david/projects/homeswitch-api/env/lib/python2.7/site-packages/pymitter/__init__.py", line 310, in __call__\n self.func(*args, **kwargs)\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/api.py", line 30, in <lambda>\n dev.on(\'status_update\', lambda status, origin: self._broadcast_status_update(dev_id, status, origin))\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/api.py", line 35, in _broadcast_status_update\n self.server.broadcast({\'devices\': {dev_id: {\'status\': status, \'origin\': origin}}})\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 48, in broadcast\n client.message(message)\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 106, in message\n self.send_http(200, body)\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 124, in send_http\n self.send(raw_body)\n', ' File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 550, in send\n self.initiate_send()\n', ' File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 537, in initiate_send\n num_sent = dispatcher.send(self, self.out_buffer[:512])\n', ' File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 380, in send\n self.handle_close()\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 95, in handle_close\n self.server.remove_user(self)\n', ' File "/Users/david/projects/homeswitch-api/homeswitch/hybridserver.py", line 51, in remove_user\n del self.clients[client.id]\n', 'KeyError: 5\n']
from homeswitch-api.
This must be related to the broadcast()
function possibly sending messages to the HTTP clients
from homeswitch-api.
According to the above stacktrace, send()
can be a source of handle_close()
events, which means that if we try to send multiple messages to a dead client handle_close()
will be called multiple times so it needs to be prepared for it.
from homeswitch-api.
Related Issues (20)
- Fix attempt to send item that is not in `waiting` state HOT 3
- Fix or handle `Operation timed out` on connect HOT 2
- Fix or handle "timeout: timed out" on send() HOT 1
- Check `[Errno 64] EHOSTDOWN` issue on connect() HOT 1
- Check `Connection reset by peer` and handle it HOT 1
- Fix infinite loop of "Should be read", Disconnect HOT 1
- Avoid Tuya connects while a connect is ongoing
- Check issue with slow connects HOT 1
- Event 'connect' called when connection is actually not established (the IP doesn't exist) HOT 1
- Socket connect timeout seems to not be working
- Ignore certain send() exceptions HOT 1
- Understand `Resource temporarily unavailable` error during socket read() HOT 1
- Understand and fix issue with socket error before connect which apparently causes issues with timers
- Crash on EHOSTUNREACH
- Infinite loop on "Socket (...) read can happen"
- Cancel command timeout in case of socket error HOT 1
- Fix double reply() attempt
- Fix slack hook issue - and Move hooks out of the API
- Fix issue with `_on_dev_reply()` wrong number of arguments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from homeswitch-api.