matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.82k stars 2.13k forks source link

HTTP client reports unhelpful log message on connection error #15745

Open Half-Shot opened 1 year ago

Half-Shot commented 1 year ago

Description

When the AS tried to access the ping endpoint, it instead gets a 502 response. The response logs are pretty unhelpful, as it doesn't explain what's actually failing.

Note: This service was working prior to an update to the bridge which caused it to start pinging the HS, so I'm fairly sure the connection to the AS should be fine.

Steps to reproduce

(I'm afraid I don't know the full steps to cause this, as I'm just reporting what I am seeing)

Homeserver

N/A

Synapse Version

1.85.1

Installation Method

Docker (matrixdotorg/synapse)

Database

PostgreSQL

Workers

Multiple workers

Platform

Kubernetes

Configuration

No response

Relevant log output

2023-06-08 08:50:52,909 - synapse.http.client - 423 - INFO - POST-136036- Error sending request to  POST http://wabridge-appservice-service:29318/_matrix/app/v1/ping: ConnectError [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
2023-06-08 08:50:52,909 - synapse.http.server - 114 - INFO - POST-136036- <XForwardedForRequest at 0x7fa0dbb894a0 method='POST' uri='/_matrix/client/v1/appservice/wabridge/ping?user_id=%40whatsappbot%3Ahost clientproto='HTTP/1.1' site='8008'> SynapseError: 502 - ConnectError: An error occurred while connecting: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
2023-06-08 08:50:52,910 - synapse.access.http.8008 - 461 - INFO - POST-136036- 13.50.81.126 - 8008 - {@whatsappbot:one.ems.host} Processed request: 0.304sec/0.000sec (0.000sec, 0.000sec) (0.000sec/0.000sec/0) 192B 502 "POST /_matrix/client/v1/appservice/wabridge/ping?user_id=%40whatsappbot%3Ahost HTTP/1.1" "mautrix-whatsapp/0.8.5-41326773fcbe0255222da58cd32c36d813ed065d+dev.unknown mautrix-go/v0.15.2 go/1.20.5" [0 dbevts]

Anything else that would be useful to know?

No response

erikjohnston commented 1 year ago

The problem is due to the connections being closed without a response (the appservice closed the connection without responding to the HTTP request.)

@Half-Shot can we close this? I'm not sure it'll be easy to make it any clearer what's going on

Half-Shot commented 1 year ago

I feel like "Connection was closed without a response" is a much clearer error than "Connection was closed cleanly".

I wouldn't usually be so bothered about it, but since the user action to take when their bridge fails to ping is "consult your homeserver logs", there needs to be some clarity about what's going wrong.

I concede though this is probably more of a Twisted issue than Synapse, so I can take this elsewhere.

erikjohnston commented 1 year ago

Hmm, I guess that's fair. Though I think it'll be a bit of a PITA to try and rewrite these connection errors TBH.