# Buggy code
async def on_socks5_tcp_data(self, tcp_connection, destination, request):
    self._logger.debug("Got request for %s: %s", destination, request)
    hops = self.socks_servers.index(tcp_connection.socksserver) + 1
    try:
        response = await self.tunnel_community.perform_http_request(
            destination, request, hops
        )
        self._logger.debug("Got response from %s: %s", destination, response)
    except RuntimeError as e:
        self._logger.info("Failed to get HTTP response using tunnels: %s", e)
        return
    tcp_connection.transport.write(response)


# Traceback (TypeError)
[PID:17022] 2020-07-10 19:04:10,150 - INFO - TunnelDispatcher(99) - Got response from ('tracker.aletorrenty.pl', 2710): None
[PID:17022] 2020-07-10 19:04:10,160 - ERROR <session:367> Session.unhandled_error_observer(): Unhandled exception occurred! data argument must be a bytes-like object, not 'NoneType'
--LONG TEXT--
Traceback (most recent call last):
File "/usr/local/lib/python3.8/asyncio/events.py", line 81, in _run
self._context.run(self._callback, *self._args)
File "/home/boogie/src/tribler/src/pyipv8/ipv8/taskmanager.py", line 131, in done_cb
future.result()
File "/home/boogie/src/tribler/src/tribler-core/tribler_core/modules/tunnel/community/dispatcher.py", line 103, in on_socks5_tcp_data
tcp_connection.transport.write(response)
File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 890, in write
raise TypeError(f'data argument must be a bytes-like object, '
TypeError: data argument must be a bytes-like object, not 'NoneType'

--CONTEXT--
{'message': 'Exception in callback TaskManager.register_task.<locals>.done_cb(<Task finishe... \'NoneType\'")>) at /home/boogie/src/tribler/src/pyipv8/ipv8/taskmanager.py:128', 'exception': TypeError("data argument must be a bytes-like object, not 'NoneType'"), 'handle': <Handle TaskManager.register_task.<locals>.done_cb(<Task finishe... 'NoneType'")>) at /home/boogie/src/tribler/src/pyipv8/ipv8/taskmanager.py:128>}
[PID:16875] 2020-07-10 19:04:10,224 - ERROR <tribler_window:107> root.on_exception(): Traceback (most recent call last):
File "/home/boogie/src/tribler/src/tribler-gui/tribler_gui/event_request_manager.py", line 112, in on_read_data
raise RuntimeError(json_dict["event"]["text"])
RuntimeError: data argument must be a bytes-like object, not 'NoneType'
--LONG TEXT--
Traceback (most recent call last):
File "/usr/local/lib/python3.8/asyncio/events.py", line 81, in _run
self._context.run(self._callback, *self._args)
File "/home/boogie/src/tribler/src/pyipv8/ipv8/taskmanager.py", line 131, in done_cb
future.result()
File "/home/boogie/src/tribler/src/tribler-core/tribler_core/modules/tunnel/community/dispatcher.py", line 103, in on_socks5_tcp_data
tcp_connection.transport.write(response)
File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 890, in write
raise TypeError(f'data argument must be a bytes-like object, '
TypeError: data argument must be a bytes-like object, not 'NoneType'

--CONTEXT--
{'message': 'Exception in callback TaskManager.register_task.<locals>.done_cb(<Task finishe... \'NoneType\'")>) at /home/boogie/src/tribler/src/pyipv8/ipv8/taskmanager.py:128', 'exception': TypeError("data argument must be a bytes-like object, not 'NoneType'"), 'handle': <Handle TaskManager.register_task.<locals>.done_cb(<Task finishe... 'NoneType'")>) at /home/boogie/src/tribler/src/pyipv8/ipv8/taskmanager.py:128>}

# Fixed code
async def on_socks5_tcp_data(self, tcp_connection, destination, request):
    self._logger.debug("Got request for %s: %s", destination, request)
    hops = self.socks_servers.index(tcp_connection.socksserver) + 1
    try:
        response = await self.tunnel_community.perform_http_request(
            destination, request, hops
        )
        self._logger.debug("Got response from %s: %s", destination, response)
    except RuntimeError as e:
        self._logger.info("Failed to get HTTP response using tunnels: %s", e)
        return

    if response:
        tcp_connection.transport.write(response)