42wim / matterircd

Connect to your mattermost or slack using your IRC-client of choice.
MIT License
294 stars 60 forks source link

No messages after laptop suspend&resume about expired session #463

Closed llunak closed 2 years ago

llunak commented 2 years ago

I connect using a personal token, which sometimes expires. If I start my IRC client in that case (or choose reconnect) I get a message in the 'mattermost' channel about the expired session. But if I suspend my laptop and resume later, there is nothing, so it looks like the session is still active, just without messages. That means that I do not get any new messages until I explicitly reconnect. I'm also connected to irc.libera.chat and IRC client detects connection loss there and reconnects (presumably because that's a remote connection while I run matterircd locally).

The log below shows starting a session around 16:22, laptop gets suspended at 23:30 and resumed at 5:50. The log repeats messages about failed login every 10 seconds until I reconnected IRC client at 8:55.

time="2022-04-27T22:15:36+02:00" level=info msg="Running version 0.25.0 71b2c97" module=matterircd
time="2022-04-27T22:15:36+02:00" level=info msg="Listening on 127.0.0.1:6668" module=matterircd
time="2022-04-27T22:15:37+02:00" level=info msg="New connection: 127.0.0.1:41140" module=matterircd
loggerlevel: info
time="2022-04-27T22:16:22+02:00" level=info msg="login as llunak (team: collabora) on chat.collabora.com"
time="2022-04-27T22:16:22+02:00" level=info msg="Found version 5.37.1.5.37.1-collabora.5a50bfd007d11728007ef9b2ac3989e3.false" prefix=matterclient
time="2022-04-27T22:16:23+02:00" level=info msg="found 238 users in team collabora" prefix=matterclient
time="2022-04-27T22:16:23+02:00" level=info msg="login succeeded"
time="2022-04-27T23:29:07+02:00" level=error msg="connection not alive: https://chat.collabora.com/api/v4/users/me: model.client.connecting.app_error, Get "https://chat.collabora.com/api/v4/users/me": dial tcp: lookup chat.collabora.com on [::1]:53: read udp [::1]:33240->[::1]:53: read: connection refused" prefix=matterclient
time="2022-04-27T23:29:47+02:00" level=error msg="got a listen error: &model.AppError{Id:"model.websocket_client.connect_fail.app_error", Message:"model.websocket_client.connect_fail.app_error", DetailedError:"read tcp 192.168.0.81:41776->46.235.227.211:443: read: connection reset by peer", RequestId:"", StatusCode:500, Where:"NewWebSocketClient", IsOAuth:false, params:map[string]interface {}(nil)}" prefix=matterclient
time="2022-04-27T23:29:47+02:00" level=error msg="connection not alive: NewWebSocketClient: model.websocket_client.connect_fail.app_error, read tcp 192.168.0.81:41776->46.235.227.211:443: read: connection reset by peer" prefix=matterclient
time="2022-04-27T23:29:58+02:00" level=error msg="got a listen error: &model.AppError{Id:"model.websocket_client.connect_fail.app_error", Message:"model.websocket_client.connect_fail.app_error", DetailedError:"read tcp 192.168.0.81:41776->46.235.227.211:443: read: connection reset by peer", RequestId:"", StatusCode:500, Where:"NewWebSocketClient", IsOAuth:false, params:map[string]interface {}(nil)}" prefix=matterclient
time="2022-04-27T23:29:58+02:00" level=info msg="reconnect: logout" prefix=matterclient
time="2022-04-27T23:29:58+02:00" level=info msg="reconnect: login" prefix=matterclient
time="2022-04-27T23:29:58+02:00" level=info msg="Found version 5.37.1.5.37.1-collabora.5a50bfd007d11728007ef9b2ac3989e3.false" prefix=matterclient
time="2022-04-27T23:29:58+02:00" level=error msg="reconnect: login failed: : Invalid or expired session, please login again., , retrying in 10 seconds" prefix=matterclient
time="2022-04-27T23:30:08+02:00" level=info msg="reconnect: login" prefix=matterclient
time="2022-04-27T23:30:08+02:00" level=info msg="Found version 5.37.1.5.37.1-collabora.5a50bfd007d11728007ef9b2ac3989e3.false" prefix=matterclient
time="2022-04-27T23:30:08+02:00" level=error msg="reconnect: login failed: : Invalid or expired session, please login again., , retrying in 10 seconds" prefix=matterclient
time="2022-04-27T23:30:18+02:00" level=info msg="reconnect: login" prefix=matterclient
time="2022-04-27T23:30:18+02:00" level=info msg="Found version 5.37.1.5.37.1-collabora.5a50bfd007d11728007ef9b2ac3989e3.false" prefix=matterclient
time="2022-04-27T23:30:18+02:00" level=error msg="reconnect: login failed: : Invalid or expired session, please login again., , retrying in 10 seconds" prefix=matterclient
time="2022-04-27T23:30:28+02:00" level=info msg="reconnect: login" prefix=matterclient
time="2022-04-27T23:30:28+02:00" level=info msg="Found version 5.37.1.5.37.1-collabora.5a50bfd007d11728007ef9b2ac3989e3.false" prefix=matterclient
time="2022-04-27T23:30:28+02:00" level=error msg="reconnect: login failed: : Invalid or expired session, please login again., , retrying in 10 seconds" prefix=matterclient
time="2022-04-28T05:50:18+02:00" level=info msg="reconnect: login" prefix=matterclient
time="2022-04-28T05:50:18+02:00" level=error msg="reconnect: login failed: "https://chat.collabora.com/api/v4/users/logout: model.client.connecting.app_error, Post \"https://chat.collabora.com/api/v4/users/logout\": dial tcp: lookup chat.collabora.com on [::1]:53: read udp [::1]:59616->[::1]:53: read: connection refused", retrying in 10 seconds" prefix=matterclient
time="2022-04-28T05:50:28+02:00" level=info msg="reconnect: login" prefix=matterclient
time="2022-04-28T05:50:28+02:00" level=error msg="reconnect: login failed: "https://chat.collabora.com/api/v4/users/logout: model.client.connecting.app_error, Post \"https://chat.collabora.com/api/v4/users/logout\": dial tcp: lookup chat.collabora.com on [::1]:53: read udp [::1]:46339->[::1]:53: read: connection refused", retrying in 10 seconds" prefix=matterclient
time="2022-04-28T05:50:38+02:00" level=info msg="reconnect: login" prefix=matterclient
time="2022-04-28T05:50:39+02:00" level=info msg="Found version 5.37.1.5.37.1-collabora.5a50bfd007d11728007ef9b2ac3989e3.false" prefix=matterclient
time="2022-04-28T05:50:39+02:00" level=error msg="reconnect: login failed: : Invalid or expired session, please login again., , retrying in 10 seconds" prefix=matterclient
...
time="2022-04-28T08:54:59+02:00" level=info msg="New connection: 127.0.0.1:41144" module=matterircd
time="2022-04-28T08:54:59+02:00" level=info msg="logout succeeded"
time="2022-04-28T08:55:02+02:00" level=info msg="reconnect: login" prefix=matterclient
time="2022-04-28T08:55:02+02:00" level=info msg="reconnect successful" prefix=matterclient
loggerlevel: info
time="2022-04-28T08:55:04+02:00" level=info msg="login as llunak (team: collabora) on chat.collabora.com"
time="2022-04-28T08:55:05+02:00" level=info msg="Found version 5.37.1.5.37.1-collabora.5a50bfd007d11728007ef9b2ac3989e3.false" prefix=matterclient
time="2022-04-28T08:55:05+02:00" level=error msg="login failed: Invalid or expired session, please login again., "
42wim commented 2 years ago

Sorry, the way the library is build, it's not possible to have those reconnect messages as a message in matterircd itself. You could make a script that tails the output and send you the error messages or a script that disconnects/connects when you put your laptop in/out sleep.

llunak commented 2 years ago

If it's not possible to have those messages in matterircd, then how come I see them if I reconnect the IRC client? Are you telling me mattericrd cannot close and setup again the socket connection to the IRC client that it is providing?

42wim commented 2 years ago

Because you see them on connect, not on reconnects. Feel free to make a PR though.