1
votes

In my application, I send a message to a topic based on a local event. This works quite well until I run into a network issue.

On the network side, my device is going through an access point that provides primary/secondary connection to the internet. The primary connection is through an ADSL line but if that fails, it switches over to an LTE network. When the switch-over occurs, the IP address of my device stays unchanged (as that is on the local network and assigned through DHCP).

When this switch-over occurs, I find that there is an error with the send command. I get my local event and try to send a message to the service bus. The first send results in a 'ReadTimeout' but a subsequent send is fine. I then get another local event and try another send and the process repeats itself. If I reboot the device then everything works fine.

Here is the stack-trace:

File "/usr/sbin/srvc/sb.py", line 420, in ReadTimeout: HTTPSConnectionPool(host='****.servicebus.windows.net', port= 443): Read timed out. (read timeout=65) Traceback (most recent call last):
File "/usr/sbin/srvc/sb.py", line 420, in peek_lock=False, timeout=sb_timeout) File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservic e.py", line 976, in receive_subscription_message timeout) File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservic e.py", line 762, in read_delete_subscription_message response = self._perform_request(request) File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservic e.py", line 1109, in _perform_request resp = self._filter(request) File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/_http/httpclient .py", line 181, in perform_request self.send_request_body(connection, request.body) File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/_http/httpclient .py", line 145, in send_request_body connection.send(None) File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/_http/requestscl ient.py", line 81, in send self.response = self.session.request(self.method, self.uri, data=request_bod y, headers=self.headers, timeout=self.timeout) File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 457, in req uest resp = self.send(prep, **send_kwargs) File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in sen d r = adapter.send(request, **kwargs) File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 422, in sen d raise ReadTimeout(e, request=request) ReadTimeout: HTTPSConnectionPool(host='****.servicebus.windows.net', port= 443): Read timed out. (read timeout=65)

1

1 Answers

-1
votes

Per my experience, I think it's a program flow problem of your embedded application.

You can try to add a testing function that ping the service bus host interval some seconds until the network fine to return a boolean value to start a new connection after the device switches the network adaptor. Meanwhile, count for pinging till a specified value to call a shell command like service network restart or ifconfig <eth-id> down && ifconfig <eth-id> up to restart the related network adaptor.

It's just an idea. Could you supply some codes for providing more useful help?