Skip to content

[Bug] Exceptions 'Bad file descriptor' thrown on EUD disconnect #206

@maxlandon

Description

@maxlandon

The following exception is sometimes being thrown by the server for different clients.
The most common stack trace I see in the logs is this:

[2025-12-01 23:49:09,726] - eud_handler[9843] - client_controller - on_channel_close - 134 - ERROR - RabbitMQ channel closed for PLD, shut it down
[2025-12-01 23:49:09,726] - eud_handler[9843] - client_controller - run - 271 - WARNING - No Data Closing connection to <IP_ADDRESS>
[2025-12-01 23:49:09,731] - eud_handler[9843] - client_controller - send_disconnect_cot - 582 - INFO - <IP_ADDRESS> disconnected
[2025-12-01 23:49:09,731] - eud_handler[9843] - client_controller - run - 304 - WARNING - OSError, stopping
[2025-12-01 23:49:09,731] - eud_handler[9843] - client_controller - run - 305 - ERROR - [Errno 9] Bad file descriptor
[2025-12-01 23:49:09,731] - eud_handler[9843] - client_controller - run - 306 - ERROR - Traceback (most recent call last):
File "/home/ubuntu/code/OpenTAKServer/opentakserver/eud_handler/client_controller.py", line 272, in run
self.close_connection()
File "/home/ubuntu/code/OpenTAKServer/opentakserver/eud_handler/client_controller.py", line 325, in close_connection
self.sock.shutdown(socket.SHUT_RDWR)
File "/usr/lib/python3.12/ssl.py", line 1291, in shutdown
super().shutdown(how)
OSError: [Errno 9] Bad file descriptor

More recently, the same exception was raised with a longer stack trace, but pretty much in the same context (client disconnecting):

[2025-12-03 05:52:13,382] - eud_handler[1047] - client_controller - run - 271 - WARNING - No Data Closing connection to <IP_ADDRESS>
[2025-12-03 05:52:13,402] - eud_handler[1047] - client_controller - send_disconnect_cot - 582 - INFO - <IP_ADDRESS> disconnected
[2025-12-03 05:52:43,401] - eud_handler[1047] - client_controller - on_channel_close - 134 - ERROR - RabbitMQ channel closed for LDN, shut it down
Exception in thread IOLOOP:
Traceback (most recent call last):
File "/usr/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/usr/lib/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/adapters/select_connection.py", line 546, in start
self._poller.start()
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/adapters/select_connection.py", line 807, in start
self._process_timeouts()
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/adapters/select_connection.py", line 495, in process_timeouts
callback()
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/diagnostic_utils.py", line 53, in log_exception_func_wrap
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/adapters/utils/io_services_utils.py", line 972, in _connection_lost_notify_async
self._protocol.connection_lost(error)
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/adapters/base_connection.py", line 431, in _proto_connection_lost
self._on_stream_terminated(error)
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/connection.py", line 2078, in _on_stream_terminated
self._channels[channel]._on_close_meta(self._error)
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/channel.py", line 1124, in _on_close_meta
self._transition_to_closed()
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/channel.py", line 1068, in _transition_to_closed
self.callbacks.process(self.channel_number, '_on_channel_close',
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/callback.py", line 60, in wrapper
return function(*tuple(args), **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/callback.py", line 92, in wrapper
return function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/code/OpenTAKServer/.venv/lib/python3.12/site-packages/pika/callback.py", line 233, in process
callback(*args, **keywords)
File "/home/ubuntu/code/OpenTAKServer/opentakserver/eud_handler/client_controller.py", line 138, in on_channel_close
self.sock.shutdown(socket.SHUT_RDWR)
File "/usr/lib/python3.12/ssl.py", line 1291, in shutdown
super().shutdown(how)
OSError: [Errno 9] Bad file descriptor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions