# Buggy code
async def websocket_handler(self, request):
    """Handle for aiohttp handling websocket connections."""
    socket = request.match_info.get("socket")
    available = [item for item in self.available_connections if item["id"] == socket]
    if len(available) != 1:
        return aiohttp.web.Response(
            text=json.dumps("Please request a socket first"),
            headers=HEADERS,
            status=400,
        )
    if (
        datetime.now() - available[0]["date"]
    ).total_seconds() > self.connection_timeout:
        self.available_connections.remove(available[0])
        return aiohttp.web.Response(
            text=json.dumps("Socket request timed out"), headers=HEADERS, status=408
        )
    self.available_connections.remove(available[0])
    _LOGGER.debug(_("User connected to %s."), socket)

    websocket = aiohttp.web.WebSocketResponse()
    await websocket.prepare(request)

    self.active_connections[socket] = websocket
    async for msg in websocket:
        if msg.type == aiohttp.WSMsgType.TEXT:
            message = Message(msg.data, None, None, self)
            await self.opsdroid.parse(message)
        elif msg.type == aiohttp.WSMsgType.ERROR:
            _LOGGER.error(
                _("Websocket connection closed with exception %s."),
                websocket.exception(),
            )

    _LOGGER.info(_("websocket connection closed"))
    self.active_connections.pop(socket, None)

    return websocket


# Traceback (AttributeError)
C:\Users\integrat>opsdroid start
INFO opsdroid.logging: ========================================
INFO opsdroid.logging: Started opsdroid v0.17.0.
INFO opsdroid: ========================================
INFO opsdroid: You can customise your opsdroid by modifying your configuration.yaml.
INFO opsdroid: Read more at: http://opsdroid.readthedocs.io/#configuration
INFO opsdroid: Watch the Get Started Videos at: http://bit.ly/2fnC0Fh
INFO opsdroid: Install Opsdroid Desktop at:
https://github.com/opsdroid/opsdroid-desktop/releases
INFO opsdroid: ========================================
WARNING opsdroid.loader: No databases in configuration. This will cause skills which store things in memory to lose data when opsdroid is restarted.
INFO opsdroid.web: Started web server on http://0.0.0.0:8080
INFO opsdroid.core: Opsdroid is now running, press ctrl+c to exit.
INFO aiohttp.access: 10.52.81.154 [21/Dec/2019:09:39:20 +0000] "POST /connector/websocket HTTP/1.1" 200 252 "-" "-"
ERROR opsdroid.core: Exception when running skill 'hello'.
Traceback (most recent call last):
File "c:\users\integrat\appdata\local\programs\python\python38-32\lib\site-packages\opsdroid\core.py", line 396, in run_skill
return await skill(event)
File "C:\Users\integrat\AppData\Local\opsdroid-modules\opsdroid\opsdroid-modules\skill\hello\__init__.py", line 13, in hello
await message.respond(text)
File "c:\users\integrat\appdata\local\programs\python\python38-32\lib\site-packages\opsdroid\events.py", line 263, in respond
"thinking-delay" in self.connector.configuration
AttributeError: 'NoneType' object has no attribute 'configuration'
ERROR aiohttp.server: Error handling request
Traceback (most recent call last):
File "c:\users\integrat\appdata\local\programs\python\python38-32\lib\site-packages\opsdroid\core.py", line 396, in run_skill
return await skill(event)
File "C:\Users\integrat\AppData\Local\opsdroid-modules\opsdroid\opsdroid-modules\skill\hello\__init__.py", line 13, in hello
await message.respond(text)
File "c:\users\integrat\appdata\local\programs\python\python38-32\lib\site-packages\opsdroid\events.py", line 263, in respond
"thinking-delay" in self.connector.configuration
AttributeError: 'NoneType' object has no attribute 'configuration'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\integrat\appdata\local\programs\python\python38-32\lib\site-packages\aiohttp\web_protocol.py", line 418, in start
resp = await task
File "c:\users\integrat\appdata\local\programs\python\python38-32\lib\site-packages\aiohttp\web_app.py", line 458, in _handle
resp = await handler(request)
File "c:\users\integrat\appdata\local\programs\python\python38-32\lib\site-packages\opsdroid\connector\websocket\__init__.py", line 101, in websocket_handler
await self.opsdroid.parse(message)
File "c:\users\integrat\appdata\local\programs\python\python38-32\lib\site-packages\opsdroid\core.py", line 509, in parse
await asyncio.gather(*tasks)
File "c:\users\integrat\appdata\local\programs\python\python38-32\lib\site-packages\opsdroid\core.py", line 402, in run_skill
await event.respond(
File "c:\users\integrat\appdata\local\programs\python\python38-32\lib\site-packages\opsdroid\events.py", line 263, in respond
"thinking-delay" in self.connector.configuration
AttributeError: 'NoneType' object has no attribute 'configuration'
INFO aiohttp.access: 10.52.81.154 [21/Dec/2019:09:39:24 +0000] "POST /connector/websocket HTTP/1.1" 200 252 "-" "-"
`

# Fixed code
async def websocket_handler(self, request):
    """Handle for aiohttp handling websocket connections."""
    socket = request.match_info.get("socket")
    available = [item for item in self.available_connections if item["id"] == socket]
    if len(available) != 1:
        return aiohttp.web.Response(
            text=json.dumps("Please request a socket first"),
            headers=HEADERS,
            status=400,
        )
    if (
        datetime.now() - available[0]["date"]
    ).total_seconds() > self.connection_timeout:
        self.available_connections.remove(available[0])
        return aiohttp.web.Response(
            text=json.dumps("Socket request timed out"), headers=HEADERS, status=408
        )
    self.available_connections.remove(available[0])
    _LOGGER.debug(_("User connected to %s."), socket)

    websocket = aiohttp.web.WebSocketResponse()
    await websocket.prepare(request)

    self.active_connections[socket] = websocket
    async for msg in websocket:
        if msg.type == aiohttp.WSMsgType.TEXT:
            message = Message(text=msg.data, user=None, target=None, connector=self)
            await self.opsdroid.parse(message)
        elif msg.type == aiohttp.WSMsgType.ERROR:
            _LOGGER.error(
                _("Websocket connection closed with exception %s."),
                websocket.exception(),
            )

    _LOGGER.info(_("websocket connection closed"))
    self.active_connections.pop(socket, None)

    return websocket